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

EmailAddress   A

Complexity

Total Complexity 3

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 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A equals() 0 3 1
A __toString() 0 3 1
A __construct() 0 3 1
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