Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| RouteStepDto | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Map\Domain\Model; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Route Step Data Transfer Object. |
| 13 | * |
| 14 | * Encapsulates a single turn-by-turn navigation maneuver instruction. |
| 15 | * |
| 16 | * @package App\Modules\Map\Domain\Model |
| 17 | */ |
| 18 | final readonly class RouteStepDto |
| 19 | { |
| 20 | /** |
| 21 | * RouteStepDto constructor. |
| 22 | * |
| 23 | * @param string $instruction Human-readable turn-by-turn maneuver description. |
| 24 | * @param float $distanceMeters Step distance in meters. |
| 25 | * @param float $durationSeconds Step estimated duration in seconds. |
| 26 | * @param string $maneuverType OSRM maneuver type (e.g. turn, depart, arrive). |
| 27 | */ |
| 28 | public function __construct( |
| 29 | public string $instruction, |
| 30 | public float $distanceMeters, |
| 31 | public float $durationSeconds, |
| 32 | public string $maneuverType = 'turn' |
| 33 | ) { |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Serializes step to array. |
| 38 | * |
| 39 | * @return array{instruction: string, distance_meters: float, duration_seconds: float, maneuver_type: string} |
| 40 | */ |
| 41 | public function toArray(): array |
| 42 | { |
| 43 | return [ |
| 44 | 'instruction' => $this->instruction, |
| 45 | 'distance_meters' => $this->distanceMeters, |
| 46 | 'duration_seconds' => $this->durationSeconds, |
| 47 | 'maneuver_type' => $this->maneuverType, |
| 48 | ]; |
| 49 | } |
| 50 | } |