Completed
Push — feature/more-metadata-values ( 439c1e...033bf1 )
by Daan van
03:58 queued 02:14
created

OrganizationDisplayName::__construct()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 8.8571
cc 5
eloc 7
nc 3
nop 2
1
<?php
2
3
namespace OpenConext\Value\Saml\Metadata\Organization;
4
5
use OpenConext\Value\Exception\InvalidArgumentException;
6
7
final class OrganizationDisplayName
8
{
9
    /**
10
     * @var string
11
     */
12
    private $displayName;
13
14
    /**
15
     * @var string
16
     */
17
    private $language;
18
19
    /**
20
     * @param $displayName
21
     * @param $language
22
     */
23
    public function __construct($displayName, $language)
24
    {
25
        if (!is_string($displayName) || trim($displayName) === '') {
26
            throw InvalidArgumentException::invalidType('non-empty string', 'displayName', $displayName);
27
        }
28
29
        if (!is_string($language) || trim($language) === '') {
30
            throw InvalidArgumentException::invalidType('non-empty string', 'language', $language);
31
        }
32
33
        $this->displayName = $displayName;
34
        $this->language = $language;
35
    }
36
37
    /**
38
     * @param OrganizationDisplayName $other
39
     * @return bool
40
     */
41
    public function equals(OrganizationDisplayName $other)
42
    {
43
        return ($this->displayName === $other->displayName && $this->language === $other->language);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getDisplayName()
50
    {
51
        return $this->displayName;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getLanguage()
58
    {
59
        return $this->language;
60
    }
61
62
    public function __toString()
63
    {
64
        return sprintf('[%s] %s', $this->language, $this->displayName);
65
    }
66
}
67