Completed
Push — feature/ra-locations ( cdde00 )
by A.
04:54
created

RaLocationName::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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