Total Complexity | 10 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class PickupPoint |
||
6 | { |
||
7 | const TYPE_TERMINAL = 0; |
||
8 | const TYPE_POST_OFFICE = 1; |
||
9 | |||
10 | private $type; |
||
11 | private $identifier; |
||
12 | |||
13 | public function __construct(string $identifier) |
||
16 | } |
||
17 | |||
18 | public function setIdentifier(string $identifier): self |
||
19 | { |
||
20 | $this->identifier = $identifier; |
||
21 | return $this; |
||
22 | } |
||
23 | |||
24 | public function getIdentifier(): string |
||
25 | { |
||
26 | return $this->identifier; |
||
27 | } |
||
28 | |||
29 | public function setType(int $type): self |
||
30 | { |
||
31 | if (!in_array($type, [self::TYPE_TERMINAL, self::TYPE_POST_OFFICE])) { |
||
32 | throw new \InvalidArgumentException('Unsupported type'); |
||
33 | } |
||
34 | |||
35 | $this->type = $type; |
||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | public function getType(): ?int |
||
42 | } |
||
43 | |||
44 | public function isPostOffice(): bool |
||
48 | } |
||
49 | |||
50 | public function isTerminal(): bool |
||
51 | { |
||
52 | $this->guardAgainstEmptyType(); |
||
53 | return $this->getType() === self::TYPE_TERMINAL; |
||
54 | } |
||
55 | |||
56 | private function guardAgainstEmptyType(): void |
||
60 | } |
||
61 | } |
||
63 |