Completed
Push — feature/more-metadata-values ( 033bf1...ebbb14 )
by Daan van
05:22 queued 02:59
created

EmailAddress::getEmailAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace OpenConext\Value\Saml\Metadata\ContactPerson;
4
5
use OpenConext\Value\Exception\InvalidArgumentException;
6
7
final class EmailAddress
8
{
9
    /**
10
     * @var string
11
     */
12
    private $emailAddress;
13
14
    public function __construct($emailAddress)
15
    {
16
        if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
17
            throw InvalidArgumentException::invalidType(
18
                'RFC 822 compliant email address',
19
                'emailAddress',
20
                $emailAddress
21
            );
22
        }
23
24
        $this->emailAddress = $emailAddress;
25
    }
26
27
    public function equals(EmailAddress $other)
28
    {
29
        return $this->emailAddress === $other->emailAddress;
30
    }
31
32
    public function getEmailAddress()
33
    {
34
        return $this->emailAddress;
35
    }
36
37
    public function __toString()
38
    {
39
        return $this->emailAddress;
40
    }
41
}
42