Completed
Push — feature/implement-is-gssf-depr... ( 334a14 )
by
unknown
13:05
created

SecondFactor::isGssf()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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\StepupGateway\GatewayBundle\Entity;
20
21
use Doctrine\ORM\Mapping as ORM;
22
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
23
use Surfnet\StepupBundle\Value\Loa;
24
use Surfnet\StepupBundle\Value\SecondFactorType;
25
26
/**
27
 * @ORM\Entity(repositoryClass="Surfnet\StepupGateway\GatewayBundle\Entity\DoctrineSecondFactorRepository")
28
 * @ORM\Table(
29
 *      indexes={
30
 *          @ORM\Index(name="idx_secondfactor_nameid", columns={"name_id"}),
31
 *      }
32
 * )
33
 * @SuppressWarnings(PHPMD.UnusedPrivateFields)
34
 */
35
class SecondFactor
36
{
37
    /**
38
     * @var int
39
     *
40
     * @ORM\Id
41
     * @ORM\Column(length=36)
42
     */
43
    private $id;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Id
49
     * @ORM\Column(length=36)
50
     */
51
    public $identityId;
52
53
    /**
54
     * @var string
55
     *
56
     * @ORM\Column(length=200)
57
     */
58
    public $nameId;
59
60
    /**
61
     * @var string
62
     *
63
     * @ORM\Column(length=200)
64
     */
65
    public $institution;
66
67
    /**
68
     * @var string
69
     *
70
     * @ORM\Column(length=36)
71
     */
72
    public $secondFactorId;
73
74
    /**
75
     * @var string
76
     *
77
     * @ORM\Column(length=50)
78
     */
79
    public $secondFactorType;
80
81
    /**
82
     * @var string
83
     *
84
     * @ORM\Column(length=255)
85
     */
86
    public $secondFactorIdentifier;
87
88
    /**
89
     * In which language to display any second factor verification screens.
90
     *
91
     * @var string
92
     *
93
     * @ORM\Column
94
     */
95
    public $displayLocale;
96
97
    /**
98
     * No new second factors should be created by the gateway
99
     */
100
    final private function __construct()
0 ignored issues
show
introduced by
Instead of declaring the constructor as final, maybe you should declare the entire class as final.
Loading history...
101
    {
102
    }
103
104
    /**
105
     * @param Loa $loa
106
     * @param SecondFactorTypeService $service
107
     * @return bool
108
     */
109
    public function canSatisfy(Loa $loa, SecondFactorTypeService $service)
110
    {
111
        $secondFactorType = new SecondFactorType($this->secondFactorType);
112
        return $service->canSatisfy($secondFactorType, $loa);
113
    }
114
115
    /**
116
     * @param SecondFactorTypeService $service
117
     * @return int
118
     */
119
    public function getLoaLevel(SecondFactorTypeService $service)
120
    {
121
        $secondFactorType = new SecondFactorType($this->secondFactorType);
122
        return $service->getLevel($secondFactorType);
123
    }
124
}
125