Completed
Push — release-1.x ( 6974c9...f5fa1d )
by Boy
10s
created

RaSecondFactor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 84
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromData() 0 17 2
A __construct() 0 3 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\StepupMiddlewareClientBundle\Identity\Dto;
20
21
use Doctrine\ORM\Mapping as ORM;
22
use JsonSerializable;
23
use Surfnet\StepupMiddlewareClientBundle\Dto\Dto;
24
25
/**
26
 * A second factor as displayed in the registration authority application. One exists for every second factor,
27
 * regardless of state. As such, it sports a status property, indicating whether its vetted, revoked etc.
28
 */
29
final class RaSecondFactor implements Dto
30
{
31
    const STATUS_UNVERIFIED = 'unverified';
32
    const STATUS_VERIFIED = 'verified';
33
    const STATUS_VETTED = 'vetted';
34
    const STATUS_REVOKED = 'revoked';
35
36
    /**
37
     * @var string The second factor's ID (UUID).
38
     */
39
    public $id;
40
41
    /**
42
     * @var string
43
     */
44
    public $type;
45
46
    /**
47
     * @var string The ID of the specific instance of second factor type (ie. phone number, Yubikey public ID).
48
     */
49
    public $secondFactorId;
50
51
    /**
52
     * @var string One of the RaSecondFactor::STATUS_* constants.
53
     */
54
    public $status;
55
56
    /**
57
     * @var string
58
     */
59
    public $identityId;
60
61
    /**
62
     * @var string
63
     */
64
    public $institution;
65
66
    /**
67
     * The name of the registrant.
68
     *
69
     * @var string
70
     */
71
    public $name;
72
73
    /**
74
     * Number of the document that was used in vetting.
75
     *
76
     * @var string|null
77
     */
78
    public $documentNumber;
79
80
    /**
81
     * The e-mail of the registrant.
82
     *
83
     * @var string
84
     */
85
    public $email;
86
87
    /**
88
     * @param array $data
89
     * @return static
90
     */
91
    public static function fromData(array $data)
92
    {
93
        $secondFactor = new self();
94
        $secondFactor->id = $data['id'];
95
        $secondFactor->type = $data['type'];
96
        $secondFactor->secondFactorId = $data['second_factor_id'];
97
        $secondFactor->status = $data['status'];
98
        $secondFactor->identityId = $data['identity_id'];
99
        $secondFactor->institution = $data['institution'];
100
        $secondFactor->name = $data['name'];
101
        if (isset($data['document_number'])) {
102
            $secondFactor->documentNumber = $data['document_number'];
103
        }
104
        $secondFactor->email = $data['email'];
105
106
        return $secondFactor;
107
    }
108
109
    private function __construct()
110
    {
111
    }
112
}
113