Total Complexity | 6 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | class Payer |
||
20 | { |
||
21 | /** |
||
22 | * array. |
||
23 | */ |
||
24 | public const OPTIONS = [ |
||
25 | 'SENDER', |
||
26 | 'RECIPIENT', |
||
27 | 'THIRD_PARTY', |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * @Serializer\Type("string") |
||
32 | */ |
||
33 | private string $value; |
||
34 | |||
35 | 3 | public function __construct(string $value) |
|
36 | { |
||
37 | 3 | if (! $this->isValid($value)) { |
|
38 | 1 | throw new \InvalidArgumentException(); |
|
39 | } |
||
40 | 2 | $this->value = $value; |
|
41 | } |
||
42 | |||
43 | 3 | private function isValid(string $value): bool |
|
44 | { |
||
45 | 3 | if (! \in_array($value, self::OPTIONS, true)) { |
|
46 | 1 | return false; |
|
47 | } |
||
48 | 2 | return true; |
|
49 | } |
||
50 | |||
51 | 1 | public function getValue(): string |
|
52 | { |
||
53 | 1 | return $this->value; |
|
54 | } |
||
55 | |||
56 | 1 | public function __toString(): string |
|
59 | } |
||
60 | } |
||
61 |