Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
|
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEmail | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setEmail | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Core\Models; |
| 4 | |
| 5 | use Core\Exceptions\ValidationException; |
| 6 | |
| 7 | class Email |
| 8 | { |
| 9 | private string $email; |
| 10 | |
| 11 | public function __construct($email) |
| 12 | { |
| 13 | $this->setEmail($email); |
| 14 | } |
| 15 | |
| 16 | public function getEmail() { |
| 17 | return $this->email; |
| 18 | } |
| 19 | |
| 20 | public function setEmail(string $email) { |
| 21 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 22 | throw new ValidationException("Email inválido", $email); |
| 23 | } |
| 24 | $this->email = $email; |
| 25 | return $this; |
| 26 | } |
| 27 | } |