Completed
Push — master ( 55e9f7...74c356 )
by A.
05:34 queued 02:39
created

SamlToken::setInstitutionConfigurationOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright 2014 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\StepupRa\RaBundle\Security\Authentication\Token;
20
21
use Surfnet\StepupBundle\Value\Loa;
22
use Surfnet\StepupMiddlewareClientBundle\Configuration\Dto\InstitutionConfigurationOptions;
23
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
24
25
class SamlToken extends AbstractToken
26
{
27
    /**
28
     * @var \SAML2_Assertion
29
     */
30
    public $assertion;
31
32
    /**
33
     * @var \Surfnet\StepupBundle\Value\Loa
34
     */
35
    private $loa;
36
37
    /**
38
     * @var InstitutionConfigurationOptions
39
     */
40
    private $institutionConfigurationOptions;
41
42
    public function __construct(Loa $loa, array $roles = [])
43
    {
44
        parent::__construct($roles);
45
46
        $this->loa = $loa;
47
        $this->setAuthenticated(count($roles));
0 ignored issues
show
Documentation introduced by
count($roles) is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
    }
49
50
    public function setInstitutionConfigurationOptions(InstitutionConfigurationOptions $institutionConfigurationOptions)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
51
    {
52
        $this->institutionConfigurationOptions = $institutionConfigurationOptions;
53
    }
54
55
    /**
56
     * @return InstitutionConfigurationOptions
57
     */
58
    public function getInstitutionConfigurationOptions()
59
    {
60
        return $this->institutionConfigurationOptions;
61
    }
62
63
    /**
64
     * Returns the user credentials.
65
     *
66
     * @return mixed The user credentials
67
     */
68
    public function getCredentials()
69
    {
70
        return '';
71
    }
72
73
    /**
74
     * @return Loa
75
     */
76
    public function getLoa()
77
    {
78
        return $this->loa;
79
    }
80
81
    public function serialize()
82
    {
83
        return serialize([parent::serialize(), $this->loa, $this->institutionConfigurationOptions]);
84
    }
85
86
    public function unserialize($serialized)
87
    {
88
        list($parent, $this->loa, $this->institutionConfigurationOptions) = unserialize($serialized);
89
90
        parent::unserialize($parent);
91
    }
92
}
93