Completed
Push — feature/fine-grained-authoriza... ( feb32c...e1bd5c )
by Michiel
03:10
created

getActorIdentity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\StepupMiddleware\ApiBundle\Authorization\Value;
20
21
use Surfnet\Stepup\Identity\Value\Institution;
22
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
23
24
class InstitutionAuthorizationContext implements InstitutionAuthorizationContextInterface
25
{
26
    /**
27
     * @var Institution
28
     */
29
    private $actorInstitution;
30
31
    /**
32
     * @var InstitutionRoleSet
33
     */
34
    private $roleRequirements;
35
36
    /**
37
     * AuthorizationContext constructor.
38
     * @param string $actorId
0 ignored issues
show
Bug introduced by
There is no parameter named $actorId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
39
     * @param string $actorInstitution
40
     * @param InstitutionRoleSetInterface $roleRequirements
41
     */
42
    public function __construct($actorInstitution, InstitutionRoleSetInterface $roleRequirements)
43
    {
44
        $this->actorInstitution = $actorInstitution;
0 ignored issues
show
Documentation Bug introduced by
It seems like $actorInstitution of type string is incompatible with the declared type object<Surfnet\Stepup\Identity\Value\Institution> of property $actorInstitution.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
        $this->roleRequirements = $roleRequirements;
0 ignored issues
show
Documentation Bug introduced by
$roleRequirements is of type object<Surfnet\StepupMid...tutionRoleSetInterface>, but the property $roleRequirements was declared to be of type object<Surfnet\StepupMid...lue\InstitutionRoleSet>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
46
    }
47
48
    /**
49
     * @return Institution
50
     */
51
    public function getActorInstitution()
52
    {
53
        return $this->actorInstitution;
54
    }
55
56
    /**
57
     * @return InstitutionRoleSet
58
     */
59
    public function getRoleRequirements()
60
    {
61
        return $this->roleRequirements;
62
    }
63
}
64