| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Email extends ValueObjectComplex |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @param mixed $value |
||
| 16 | * @param mixed ...$other |
||
| 17 | * @throws \ReflectionException |
||
| 18 | */ |
||
| 19 | 2 | public function guard($value, ...$other): void |
|
| 20 | { |
||
| 21 | 2 | parent::guard($value); |
|
| 22 | /** @var ValueObjectInterface $value*/ |
||
| 23 | 2 | if (filter_var($value->getValue(), FILTER_VALIDATE_EMAIL) === false) { |
|
| 24 | 1 | throw new InvalidVOArgumentException('Value is not a valid e-mail address.', $value); |
|
| 25 | } |
||
| 26 | 1 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | 1 | public function userName(): string |
|
| 32 | { |
||
| 33 | 1 | return $this->getEmailParts()[0]; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | 1 | public function domain(): string |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param string $value |
||
| 46 | * @return Email |
||
| 47 | * @throws \ReflectionException |
||
| 48 | */ |
||
| 49 | 2 | public static function createFromString(string $value): self |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return array |
||
| 56 | */ |
||
| 57 | 1 | private function getEmailParts(): array |
|
| 62 |