| Conditions | 4 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | 6 | public function __construct($email, $is_required = true) |
|
| 15 | { |
||
| 16 | 6 | static $empty_values = [null, '']; |
|
| 17 | |||
| 18 | 6 | if (!$is_required && in_array($email, $empty_values, true)) { |
|
| 19 | 1 | $email = null; |
|
| 20 | 6 | } elseif (filter_var($email, \FILTER_VALIDATE_EMAIL) === false) { |
|
| 21 | 4 | throw new InvalidArgumentException('Value must be an email address'); |
|
| 22 | } |
||
| 23 | |||
| 24 | 2 | $this->email = $email; |
|
| 25 | 2 | } |
|
| 26 | |||
| 32 |