Total Complexity | 9 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class Email implements \JsonSerializable |
||
16 | { |
||
17 | private string $value; |
||
18 | |||
19 | 6 | public function __construct(string $value) |
|
20 | { |
||
21 | 6 | $this->setValue($value); |
|
22 | } |
||
23 | |||
24 | 1 | public function getValue(): string |
|
25 | { |
||
26 | 1 | return $this->value; |
|
27 | } |
||
28 | |||
29 | 6 | private function setValue(string $value): void |
|
30 | { |
||
31 | 6 | if (! \filter_var($value, \FILTER_VALIDATE_EMAIL)) { |
|
32 | 1 | throw new \InvalidArgumentException(); |
|
33 | } |
||
34 | 5 | $this->value = $value; |
|
35 | } |
||
36 | |||
37 | 1 | public function compareTo(self $other): int |
|
38 | { |
||
39 | 1 | return \strcasecmp($this->getValue(), $other->getValue()); |
|
40 | } |
||
41 | |||
42 | 1 | public function equals(self $other): bool |
|
45 | } |
||
46 | |||
47 | 1 | final public function __toString(): string |
|
48 | { |
||
49 | 1 | return $this->value; |
|
50 | } |
||
51 | |||
52 | 1 | public function jsonSerialize(): string |
|
55 | } |
||
56 | |||
57 | 1 | public function toArray(): array |
|
60 | } |
||
61 | } |
||
62 |