Passed
Push — master ( a50425...6eae0f )
by Serhii
01:54
created

EmailAddress::equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 27
    public function __construct(string $emailAddress)
21
    {
22 27
        $this->emailAddress = Assertion::email($emailAddress);
23 21
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28 6
    public function equals(EmailAddressInterface $emailAddress): bool
29
    {
30 6
        return $this->emailAddress === $emailAddress->emailAddress;
0 ignored issues
show
Bug introduced by
Accessing emailAddress on the interface Nordic\EmailAddress\EmailAddressInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36 12
    public function __toString(): string
37
    {
38 12
        return $this->emailAddress;
39
    }
40
}
41