Endpoint   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getBinding() 0 4 1
A getLocation() 0 4 1
A getResponseLocation() 0 4 1
A equals() 0 6 3
A deserialize() 0 7 1
A serialize() 0 8 1
A __toString() 0 9 2
1
<?php
2
3
namespace OpenConext\Value\Saml\Metadata\Common;
4
5
use OpenConext\Value\Assert\Assertion;
6
use OpenConext\Value\Serializable;
7
8
final class Endpoint implements Serializable
9
{
10
    /**
11
     * @var Binding
12
     */
13
    private $binding;
14
15
    /**
16
     * @var string
17
     */
18
    private $location;
19
20
    /**
21
     * @var null|string
22
     */
23
    private $responseLocation;
24
25
    /**
26
     * @param Binding     $binding
27
     * @param string      $location
28
     * @param null|string $responseLocation
29
     */
30
    public function __construct(Binding $binding, $location, $responseLocation = null)
31
    {
32
        Assertion::nonEmptyString($location, 'location');
33
        Assertion::nullOrNonEmptyString($responseLocation, 'responseLocation');
34
35
        $this->binding = $binding;
36
        $this->location = $location;
37
        $this->responseLocation = $responseLocation;
38
    }
39
40
    /**
41
     * @return Binding
42
     */
43
    public function getBinding()
44
    {
45
        return $this->binding;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getLocation()
52
    {
53
        return $this->location;
54
    }
55
56
    /**
57
     * @return null|string
58
     */
59
    public function getResponseLocation()
60
    {
61
        return $this->responseLocation;
62
    }
63
64
    /**
65
     * @param Endpoint $other
66
     * @return bool
67
     */
68
    public function equals(Endpoint $other)
69
    {
70
        return $this->binding->equals($other->binding)
71
                && $this->location === $other->location
72
                && $this->responseLocation === $other->responseLocation;
73
    }
74
75
    public static function deserialize($data)
76
    {
77
        Assertion::isArray($data);
78
        Assertion::keysExist($data, array('binding', 'location', 'response_location'));
79
80
        return new self(Binding::deserialize($data['binding']), $data['location'], $data['response_location']);
81
    }
82
83
    public function serialize()
84
    {
85
        return array(
86
            'binding' => $this->binding->serialize(),
87
            'location' => $this->location,
88
            'response_location' => $this->responseLocation
89
        );
90
    }
91
92
    public function __toString()
93
    {
94
        return sprintf(
95
            'Endpoint(Binding=%s, Location=%s, ResponseLocation=%s',
96
            (string) $this->binding,
97
            $this->location,
98
            ($this->responseLocation ?: 'null')
99
        );
100
    }
101
}
102