VettedSecondFactor::vettingType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 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
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
18
19
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
20
21
use Doctrine\ORM\Mapping as ORM;
22
use JsonSerializable;
23
use Surfnet\Stepup\Identity\Value\VettingType;
24
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository;
25
26
#[ORM\Table]
27
#[ORM\Index(name: 'idx_vetted_second_factor_type', columns: ['type'])]
28
#[ORM\Index(name: 'idx_vetted_second_factor_vetting_type', columns: ['vetting_type'])]
29
#[ORM\Entity(repositoryClass: VettedSecondFactorRepository::class)]
30
class VettedSecondFactor implements JsonSerializable
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class VettedSecondFactor
Loading history...
31
{
32
    #[ORM\Id]
33
    #[ORM\Column(length: 36)]
34
    public string $id;
35
36
    #[ORM\Column(length: 36)]
37
    public string $identityId;
38
39
    #[ORM\Column(length: 16)]
40
    public string $type;
41
42
    #[ORM\Column(length: 255)]
43
    public string $secondFactorIdentifier;
44
45
    #[ORM\Column(length: 255, nullable: true)]
46
    public ?string $vettingType = null;
47
48
    public function isEqual(VettedSecondFactor $vettedSecondFactor): bool
49
    {
50
        return $vettedSecondFactor->type === $this->type && $vettedSecondFactor->secondFactorIdentifier === $this->secondFactorIdentifier;
51
    }
52
53
    public function vettingType(): string
54
    {
55
        if (!$this->vettingType) {
56
            return VettingType::TYPE_ON_PREMISE;
57
        }
58
        return $this->vettingType;
59
    }
60
61
    public function jsonSerialize(): array
62
    {
63
        return [
64
            'id' => $this->id,
65
            'type' => $this->type,
66
            'second_factor_identifier' => $this->secondFactorIdentifier,
67
            'vetting_type' => $this->vettingType,
68
        ];
69
    }
70
}
71