EmailAddress   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 3 1
A equals() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nordic\EmailAddress;
6
7
/**
8
 * Immutable email address value object
9
 */
10
class EmailAddress implements EmailAddressInterface
11
{
12
    /** @var string */
13
    private $emailAddress;
14
15
    /**
16
     * Constructor
17
     *
18
     * @throws \Nordic\EmailAddress\InvalidEmailAddressException
19
     */
20 33
    public function __construct(string $emailAddress)
21
    {
22 33
        $this->emailAddress = Assertion::email($emailAddress);
23 27
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28 9
    public function equals(EmailAddressInterface $emailAddress): bool
29
    {
30 9
        return $emailAddress instanceof self && $emailAddress->emailAddress === $this->emailAddress;
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36 12
    public function __toString(): string
37
    {
38 12
        return $this->emailAddress;
39
    }
40
}
41