mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
915 B
PHP
33 lines
915 B
PHP
<?php
|
|
|
|
namespace App\Data\Traffic;
|
|
|
|
use Spatie\LaravelData\Data;
|
|
|
|
class TrafficBreakdownData extends Data
|
|
{
|
|
public function __construct(
|
|
public string $value,
|
|
public int $requests,
|
|
public int $bytesOut,
|
|
public ?float $lat = null,
|
|
public ?float $lon = null,
|
|
) {}
|
|
|
|
public static function fromSentinel(array $row): self
|
|
{
|
|
$lat = data_get($row, 'lat');
|
|
$lon = data_get($row, 'lon');
|
|
$hasCoordinates = is_numeric($lat) && is_numeric($lon)
|
|
&& abs((float) $lat) <= 90 && abs((float) $lon) <= 180;
|
|
|
|
return new self(
|
|
value: (string) data_get($row, 'value', ''),
|
|
requests: (int) data_get($row, 'requests', 0),
|
|
bytesOut: (int) data_get($row, 'bytes_out', 0),
|
|
lat: $hasCoordinates ? (float) $lat : null,
|
|
lon: $hasCoordinates ? (float) $lon : null,
|
|
);
|
|
}
|
|
}
|