VerifiedSecondFactor::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
rs 9.9666
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
 */
18
19
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
20
21
use Doctrine\ORM\Mapping as ORM;
22
use JsonSerializable;
23
use Surfnet\Stepup\DateTime\DateTime;
24
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository;
25
26
#[ORM\Table]
27
#[ORM\Index(name: 'idx_institution', columns: ['institution'])]
28
#[ORM\Entity(repositoryClass: VerifiedSecondFactorRepository::class)]
29
class VerifiedSecondFactor implements JsonSerializable
30
{
31
    #[ORM\Id]
32
    #[ORM\Column(length: 36)]
33
    public string $id;
34
35
    #[ORM\Column(length: 36)]
36
    public string $identityId;
37
38
    #[ORM\Column]
39
    public string $institution;
40
41
    #[ORM\Column]
42
    public string $commonName;
43
44
    #[ORM\Column(length: 16)]
45
    public string $type;
46
47
    /**
48
     * The second factor identifier, ie. telephone number, Yubikey public ID, Tiqr ID
49
     */
50
    #[ORM\Column(length: 255)]
51
    public string $secondFactorIdentifier;
52
53
    #[ORM\Column(length: 8)]
54
    public string $registrationCode;
55
56
    #[ORM\Column(type: 'stepup_datetime')]
57
    public DateTime $registrationRequestedAt;
58
59
    public function jsonSerialize(): array
60
    {
61
        return [
62
            'id' => $this->id,
63
            'type' => $this->type,
64
            'second_factor_identifier' => $this->secondFactorIdentifier,
65
            'registration_code' => $this->registrationCode,
66
            'registration_requested_at' => $this->registrationRequestedAt->format('c'),
67
            'identity_id' => $this->identityId,
68
            'institution' => $this->institution,
69
            'common_name' => $this->commonName,
70
        ];
71
    }
72
}
73