Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Email
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 value
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 equals
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Identity\Domain\ValueObject;
6
7use InvalidArgumentException;
8
9final class Email
10{
11    public function __construct(private readonly string $value)
12    {
13        if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
14            throw new InvalidArgumentException(sprintf('Invalid email address <%s>.', $value));
15        }
16    }
17
18    public function __toString(): string
19    {
20        return $this->value;
21    }
22
23    public function value(): string
24    {
25        return $this->value;
26    }
27
28    public function equals(self $other): bool
29    {
30        return $this->value === $other->value;
31    }
32}