Completed
Push — feature/more-metadata-values ( 2453e1...150bb6 )
by Daan van
03:33
created

OrganizationDisplayName   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 6
c 4
b 0
f 1
lcom 1
cbo 0
dl 0
loc 55
rs 10

5 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 __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\Exception\InvalidArgumentException;
7
8
final class OrganizationDisplayName
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 function __toString()
59
    {
60
        return sprintf('[%s] %s', $this->language, $this->displayName);
61
    }
62
}
63