Completed
Pull Request — develop (#9)
by Daan van
10:15 queued 07:39
created

EmailAddress   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A equals() 0 4 1
A getEmailAddress() 0 4 1
A __toString() 0 4 1
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
    /**
15
     * @param string $emailAddress RFC 822 compliant email address
16
     */
17
    public function __construct($emailAddress)
18
    {
19
        if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
20
            throw InvalidArgumentException::invalidType(
21
                'RFC 822 compliant email address',
22
                'emailAddress',
23
                $emailAddress
24
            );
25
        }
26
27
        $this->emailAddress = $emailAddress;
28
    }
29
30
    /**
31
     * @param EmailAddress $other
32
     * @return bool
33
     */
34
    public function equals(EmailAddress $other)
35
    {
36
        return $this->emailAddress === $other->emailAddress;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getEmailAddress()
43
    {
44
        return $this->emailAddress;
45
    }
46
47
    public function __toString()
48
    {
49
        return $this->emailAddress;
50
    }
51
}
52