OrganizationDisplayName::getLanguage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace OpenConext\Value\Saml\Metadata\Organization;
4
5
use OpenConext\Value\Assert\Assertion;
6
use OpenConext\Value\Serializable;
7
8
final class OrganizationDisplayName implements Serializable
9
{
10
    /**
11
     * @var string
12
     */
13
    private $displayName;
14
15
    /**
16
     * @var string
17
     */
18
    private $language;
19
20
    /**
21
     * @param string $displayName
22
     * @param string $language
23
     */
24
    public function __construct($displayName, $language)
25
    {
26
        Assertion::nonEmptyString($displayName, 'displayName');
27
        Assertion::nonEmptyString($language, 'language');
28
29
        $this->displayName = $displayName;
30
        $this->language = $language;
31
    }
32
33
    /**
34
     * @param OrganizationDisplayName $other
35
     * @return bool
36
     */
37
    public function equals(OrganizationDisplayName $other)
38
    {
39
        return ($this->displayName === $other->displayName && $this->language === $other->language);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getDisplayName()
46
    {
47
        return $this->displayName;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getLanguage()
54
    {
55
        return $this->language;
56
    }
57
58
    public static function deserialize($data)
59
    {
60
        Assertion::isArray($data);
61
        Assertion::keysExist($data, array('display_name', 'language'));
62
63
        return new self($data['display_name'], $data['language']);
64
    }
65
66
    public function serialize()
67
    {
68
        return array(
69
            'display_name' => $this->displayName,
70
            'language' => $this->language
71
        );
72
    }
73
74
    public function __toString()
75
    {
76
        return sprintf('[%s] %s', $this->language, $this->displayName);
77
    }
78
}
79