Completed
Push — feature/export-raa-token-infor... ( 95b8f8 )
by
unknown
02:43
created

ExportRaSecondFactorsCommand::fromSearchCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 11
nc 1
nop 2
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.institution.blank")
32
     * @Assert\Type("string", message="ra.search_ra_second_factors.institution.type")
33
     *
34
     * @var string
35
     */
36
    public $institution;
37
38
    /**
39
     * @var string|null
40
     */
41
    public $name;
42
43
    /**
44
     * @Assert\Choice({"sms", "yubikey", "tiqr"}, message="ra.search_ra_second_factors.type.invalid_choice")
45
     *
46
     * @var string|null
47
     */
48
    public $type;
49
50
    /**
51
     * @var string|null The second factor type's ID (eg. Yubikey public ID)
52
     */
53
    public $secondFactorId;
54
55
    /**
56
     * @var string|null
57
     */
58
    public $email;
59
60
    /**
61
     * @Assert\Choice(
62
     *     {"unverified", "verified", "vetted", "revoked"},
63
     *     message="ra.search_ra_second_factors.status.invalid_choice"
64
     * )
65
     *
66
     * @var string|null One of the STATUS_* constants.
67
     */
68
    public $status;
69
70
    /**
71
     * @Assert\Choice(
72
     *     {"name", "type", "secondFactorId", "email", "status"},
73
     *     message="ra.search_ra_second_factors.order_by.invalid_choice"
74
     * )
75
     *
76
     * @var string|null
77
     */
78
    public $orderBy;
79
80
    /**
81
     * @Assert\Choice({"asc", "desc"}, message="ra.search_ra_second_factors.order_direction.invalid_choice")
82
     *
83
     * @var string|null
84
     */
85
    public $orderDirection;
86
87
    /**
88
     * Builds the command from a SearchRaSecondFactorsCommand
89
     * @param SearchRaSecondFactorsCommand $command
90
     * @param string $institution
91
     * @return ExportRaSecondFactorsCommand
92
     */
93
    public static function fromSearchCommand(SearchRaSecondFactorsCommand $command, $institution)
94
    {
95
        $exportCommand = new self;
96
97
        $exportCommand->name = $command->name;
98
        $exportCommand->type = $command->type;
99
        $exportCommand->secondFactorId = $command->secondFactorId;
100
        $exportCommand->email = $command->email;
101
        $exportCommand->status = $command->status;
102
        $exportCommand->orderBy = $command->orderBy;
103
        $exportCommand->orderDirection = $command->orderDirection;
104
        $exportCommand->institution = $institution;
105
106
        return $exportCommand;
107
    }
108
}
109