| Conditions | 4 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function __construct(string $emailAddress) |
||
| 15 | { |
||
| 16 | $addressParts = explode('@', $emailAddress); |
||
| 17 | |||
| 18 | if (!is_array($addressParts) || count($addressParts) !== 2) { |
||
|
|
|||
| 19 | throw new InvalidArgumentException('Given email address could not be parsed'); |
||
| 20 | } |
||
| 21 | |||
| 22 | $this->userName = $addressParts[0]; |
||
| 23 | $this->domain = $addressParts[1]; |
||
| 24 | |||
| 25 | if (trim($this->domain) === '') { |
||
| 26 | throw new InvalidArgumentException('Email domain cannot be empty'); |
||
| 27 | } |
||
| 61 | } |