1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2018 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\Stepup\Identity\Entity; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Value\Institution; |
22
|
|
|
|
23
|
|
|
final class RegistrationAuthorityCollection |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var RegistrationAuthority[] |
27
|
|
|
*/ |
28
|
|
|
private $registrationAuthorities = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Institution $institution |
32
|
|
|
* @param RegistrationAuthority $registrationAuthority |
33
|
|
|
*/ |
34
|
|
|
public function set(Institution $institution, RegistrationAuthority $registrationAuthority) |
35
|
|
|
{ |
36
|
|
|
$this->registrationAuthorities[(string)$institution] = $registrationAuthority; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param Institution $institution |
41
|
|
|
* @return RegistrationAuthority |
42
|
|
|
*/ |
43
|
|
|
public function get(Institution $institution) |
44
|
|
|
{ |
45
|
|
|
return $this->registrationAuthorities[(string)$institution]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param Institution $institution |
50
|
|
|
* @return RegistrationAuthority |
|
|
|
|
51
|
|
|
*/ |
52
|
|
|
public function exists(Institution $institution) |
53
|
|
|
{ |
54
|
|
|
return array_key_exists((string)$institution, $this->registrationAuthorities); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param Institution $institution |
59
|
|
|
*/ |
60
|
|
|
public function remove(Institution $institution) |
61
|
|
|
{ |
62
|
|
|
unset($this->registrationAuthorities[(string)$institution]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return int |
67
|
|
|
*/ |
68
|
|
|
public function count() |
69
|
|
|
{ |
70
|
|
|
return count($this->registrationAuthorities); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* RegistrationAuthority[] |
75
|
|
|
*/ |
76
|
|
|
public function getValues() |
77
|
|
|
{ |
78
|
|
|
return array_values($this->registrationAuthorities); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.