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

InstitutionCollection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 59
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 1
A update() 0 6 2
A get() 0 4 1
A exists() 0 4 1
A remove() 0 4 1
A count() 0 4 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\Configuration\Value\InstitutionRole;
22
use Surfnet\Stepup\Identity\Value\Institution;
23
use \Surfnet\Stepup\Identity\Collection\InstitutionCollection as Institutions;
24
25
final class InstitutionCollection
26
{
27
    /**
28
     * @var InstitutionRole[]
29
     */
30
    private $institutions = [];
31
32
    /**
33
     * @param Institution $institution
34
     */
35
    public function set(Institution $institution)
36
    {
37
        $this->institutions[(string)$institution] = $institution;
38
    }
39
40
    /**
41
     * @param Institutions $institutions
42
     */
43
    public function update(Institutions $institutions)
44
    {
45
        foreach ($institutions as $institution) {
46
            $this->institutions[(string)$institutions] = $institution;
47
        }
48
    }
49
50
    /**
51
     * @param Institution $institution
52
     * @return Institution
0 ignored issues
show
Documentation introduced by
Should the return type not be InstitutionRole?

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...
53
     */
54
    public function get(Institution $institution)
55
    {
56
        return $this->institutions[(string)$institution];
57
    }
58
59
    /**
60
     * @param Institution $institution
61
     * @return Institution
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...
62
     */
63
    public function exists(Institution $institution)
64
    {
65
        return array_key_exists((string)$institution, $this->institutions);
66
    }
67
68
    /**
69
     * @param Institution $institution
70
     */
71
    public function remove(Institution $institution)
72
    {
73
        unset($this->institutions[(string)$institution]);
74
    }
75
76
    /**
77
     * @return int
78
     */
79
    public function count()
80
    {
81
        return count($this->institutions);
82
    }
83
}
84