ExportRaSecondFactorsCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 89
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromSearchCommand() 0 16 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\StepupRa\RaBundle\Command;
20
21
use Symfony\Component\Validator\Constraints as Assert;
22
23
final class ExportRaSecondFactorsCommand
24
{
25
    const STATUS_UNVERIFIED = 'unverified';
26
    const STATUS_VERIFIED = 'verified';
27
    const STATUS_VETTED = 'vetted';
28
    const STATUS_REVOKED = 'revoked';
29
30
    /**
31
     * @Assert\NotBlank(message="ra.search_ra_second_factors.actor.blank")
32
     * @Assert\Type("string", message="ra.search_ra_second_factors.actor.type")
33
     *
34
     * @var string
35
     */
36
    public $actorId;
37
38
    /**
39
     * @var string|null
40
     */
41
    public $name;
42
43
    /**
44
     * @var string|null
45
     */
46
    public $type;
47
48
    /**
49
     * @var string|null The second factor type's ID (eg. Yubikey public ID)
50
     */
51
    public $secondFactorId;
52
53
    /**
54
     * @var string|null
55
     */
56
    public $email;
57
58
    /**
59
     * @var string|null
60
     */
61
    public $institution;
62
63
    /**
64
     * @Assert\Choice(
65
     *     {"unverified", "verified", "vetted", "revoked"},
66
     *     message="ra.search_ra_second_factors.status.invalid_choice"
67
     * )
68
     *
69
     * @var string|null One of the STATUS_* constants.
70
     */
71
    public $status;
72
73
    /**
74
     * @Assert\Choice(
75
     *     {"name", "type", "secondFactorId", "email", "status"},
76
     *     message="ra.search_ra_second_factors.order_by.invalid_choice"
77
     * )
78
     *
79
     * @var string|null
80
     */
81
    public $orderBy;
82
83
    /**
84
     * @Assert\Choice({"asc", "desc"}, message="ra.search_ra_second_factors.order_direction.invalid_choice")
85
     *
86
     * @var string|null
87
     */
88
    public $orderDirection;
89
90
    /**
91
     * Builds the command from a SearchRaSecondFactorsCommand
92
     * @param SearchRaSecondFactorsCommand $command
93
     * @return ExportRaSecondFactorsCommand
94
     */
95
    public static function fromSearchCommand(SearchRaSecondFactorsCommand $command)
96
    {
97
        $exportCommand = new self;
98
99
        $exportCommand->actorId = $command->actorId;
100
        $exportCommand->name = $command->name;
101
        $exportCommand->type = $command->type;
102
        $exportCommand->secondFactorId = $command->secondFactorId;
103
        $exportCommand->email = $command->email;
104
        $exportCommand->institution = $command->institution;
105
        $exportCommand->status = $command->status;
106
        $exportCommand->orderBy = $command->orderBy;
107
        $exportCommand->orderDirection = $command->orderDirection;
108
109
        return $exportCommand;
110
    }
111
}
112