OrganizationDisplayName   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A equals() 0 4 2
A getDisplayName() 0 4 1
A getLanguage() 0 4 1
A deserialize() 0 7 1
A serialize() 0 7 1
A __toString() 0 4 1
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