| Total Complexity | 5 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Element |
||
| 9 | { |
||
| 10 | public const STATUS_OK = 'OK'; |
||
| 11 | public const STATUS_FAILED = 'failed'; |
||
| 12 | public const STATUS_NOT_FOUND = 'NOT_FOUND'; |
||
| 13 | public const STATUS_ZERO_RESULTS = 'ZERO_RESULTS'; |
||
| 14 | |||
| 15 | public const STATUS = [ |
||
| 16 | self::STATUS_OK, |
||
| 17 | self::STATUS_FAILED, |
||
| 18 | self::STATUS_NOT_FOUND, |
||
| 19 | self::STATUS_ZERO_RESULTS, |
||
| 20 | ]; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $status; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var ?Duration |
||
| 29 | */ |
||
| 30 | private $duration; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var ?Distance |
||
| 34 | */ |
||
| 35 | private $distance; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Element constructor. |
||
| 39 | * |
||
| 40 | * @throws \Exception |
||
| 41 | */ |
||
| 42 | public function __construct(string $status, ?Duration $duration, ?Distance $distance) |
||
| 43 | { |
||
| 44 | if (!\in_array($status, self::STATUS, true)) { |
||
| 45 | throw new \Exception(sprintf('Unknown status code: %s', $status)); |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->status = $status; |
||
| 49 | $this->duration = $duration; |
||
| 50 | $this->distance = $distance; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function getStatus(): string |
||
| 54 | { |
||
| 55 | return $this->status; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function getDuration(): ?Duration |
||
| 61 | } |
||
| 62 | |||
| 63 | public function getDistance(): ?Distance |
||
| 66 | } |
||
| 67 | } |
||
| 68 |