Completed
Push — master ( ed3593...2f770f )
by Boy
9s
created

VerifiedSecondFactor::fromData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 13
Ratio 100 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 13
loc 13
rs 9.4285
cc 1
eloc 10
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\StepupMiddlewareClientBundle\Identity\Dto;
20
21
use Surfnet\StepupMiddlewareClientBundle\Dto\Dto;
22
use Symfony\Component\Validator\Constraints as Assert;
23
24 View Code Duplication
class VerifiedSecondFactor implements Dto
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    /**
27
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.id.must_not_be_blank")
28
     * @Assert\Type(type="string", message="middleware_client.dto.verified_second_factor.id.must_be_string")
29
     * @var string
30
     */
31
    public $id;
32
33
    /**
34
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.type.must_not_be_blank")
35
     * @Assert\Type(type="string", message="middleware_client.dto.verified_second_factor.type.must_be_string")
36
     * @var string
37
     */
38
    public $type;
39
40
    /**
41
     * @Assert\NotBlank(
42
     *     message="middleware_client.dto.verified_second_factor.second_factor_identifier.must_not_be_blank"
43
     * )
44
     * @Assert\Type(
45
     *     type="string",
46
     *     message="middleware_client.dto.verified_second_factor.second_factor_identifier.must_be_string"
47
     * )
48
     * @var string
49
     */
50
    public $secondFactorIdentifier;
51
52
    /**
53
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.registration_code.must_not_be_blank")
54
     * @Assert\Type(
55
     *     type="string",
56
     *     message="middleware_client.dto.verified_second_factor.registration_code.must_be_string"
57
     * )
58
     * @var string
59
     */
60
    public $registrationCode;
61
62
    /**
63
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.identity_id.must_not_be_blank")
64
     * @Assert\Type(
65
     *     type="string",
66
     *     message="middleware_client.dto.verified_second_factor.identity_id.must_be_string"
67
     * )
68
     * @var string
69
     */
70
    public $identityId;
71
72
    /**
73
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.institution.must_not_be_blank")
74
     * @Assert\Type(
75
     *     type="string",
76
     *     message="middleware_client.dto.verified_second_factor.institution.must_be_string"
77
     * )
78
     * @var string
79
     */
80
    public $institution;
81
82
    /**
83
     * @Assert\NotBlank(message="middleware_client.dto.verified_second_factor.common_name.must_not_be_blank")
84
     * @Assert\Type(
85
     *     type="string",
86
     *     message="middleware_client.dto.verified_second_factor.common_name.must_be_string"
87
     * )
88
     * @var string
89
     */
90
    public $commonName;
91
92
    public static function fromData(array $data)
93
    {
94
        $secondFactor = new self();
95
        $secondFactor->id = $data['id'];
96
        $secondFactor->type = $data['type'];
97
        $secondFactor->secondFactorIdentifier = $data['second_factor_identifier'];
98
        $secondFactor->registrationCode = $data['registration_code'];
99
        $secondFactor->identityId = $data['identity_id'];
100
        $secondFactor->institution = $data['institution'];
101
        $secondFactor->commonName = $data['common_name'];
102
103
        return $secondFactor;
104
    }
105
}
106