EmailAddress::equals()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
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