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