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

Surname::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace OpenConext\Value\Saml\Metadata\ContactPerson;
4
5
use OpenConext\Value\Exception\InvalidArgumentException;
6
7
final class Surname
8
{
9
    /**
10
     * @var string
11
     */
12
    private $surname;
13
14
    /**
15
     * @param string $name
16
     */
17
    public function __construct($name)
18
    {
19
        if (!is_string($name) || trim($name) === '') {
20
            throw InvalidArgumentException::invalidType('non-empty string', 'name', $name);
21
        }
22
23
        $this->surname = $name;
24
    }
25
26
    /**
27
     * @param Surname $other
28
     * @return bool
29
     */
30
    public function equals(Surname $other)
31
    {
32
        return $this->surname === $other->surname;
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getSurname()
39
    {
40
        return $this->surname;
41
    }
42
43
    public function __toString()
44
    {
45
        return $this->surname;
46
    }
47
}
48