Cleanup SI Unit classes and interface for REST responses; fixes to a few METAR parsing issues

This commit is contained in:
Nabeel Shahzad
2019-07-15 15:14:40 -04:00
parent 466d04caf7
commit 06d8f11ca3
33 changed files with 399 additions and 222 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Interfaces\Unit;
use Illuminate\Http\Resources\Json\Resource;
/**
@@ -9,4 +10,22 @@ use Illuminate\Http\Resources\Json\Resource;
*/
class Response extends Resource
{
/**
* Iterate through the list of $fields and check if they're a "Unit"
* If they are, then add the response
*
* @param $response
* @param array $fields
*/
public function checkUnitFields(&$response, array $fields): void
{
foreach ($fields as $f) {
if ($this->{$f} instanceof Unit) {
$response[$f] = $this->{$f}->getResponseUnits();
} else {
$response[$f] = $this->{$f};
}
}
}
}