Completed
Pull Request — feature/fine-grained-authoriza... (#246)
by
unknown
40:56 queued 21:52
created

RegistrationAuthorityCollection::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
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
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean?

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.

Loading history...
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