Completed
Push — master ( d2aa7f...78f4d4 )
by Michiel
03:30 queued 02:21
created

setActorInstitution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
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\StepupMiddlewareClient\Identity\Dto;
20
21
use Assert;
22
use Surfnet\StepupMiddlewareClient\Dto\HttpQuery;
23
24
class VerifiedSecondFactorSearchQuery implements HttpQuery
25
{
26
    /**
27
     * @var string
28
     */
29
    private $identityId;
30
31
    /**
32
     * @var string
33
     */
34
    private $secondFactorId;
35
36
    /**
37
     * @var string
38
     */
39
    private $registrationCode;
40
41
    /**
42
     * @var string
43
     */
44
    private $actorInstitution;
45
46
    /**
47
     * @var string
48
     */
49
    private $institution;
50
    /**
51
     * @var string
52
     */
53
    private $actorId;
54
55
    /**
56
     * @param string $identityId
57
     * @return self
58
     */
59
    public function setIdentityId($identityId)
60
    {
61
        $this->assertNonEmptyString($identityId, 'identityId');
62
63
        $this->identityId = $identityId;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @param string $secondFactorId
70
     * @return self
71
     */
72
    public function setSecondFactorId($secondFactorId)
73
    {
74
        $this->assertNonEmptyString($secondFactorId, 'secondFactorId');
75
76
        $this->secondFactorId = $secondFactorId;
77
78
        return $this;
79
    }
80
81
    /**
82
     * @param string $registrationCode
83
     * @return self
84
     */
85
    public function setRegistrationCode($registrationCode)
86
    {
87
        $this->assertNonEmptyString($registrationCode, 'registrationCode');
88
89
        $this->registrationCode = $registrationCode;
90
91
        return $this;
92
    }
93
94
    /**
95
     * @param string $actorInstitution
96
     * @return VerifiedSecondFactorSearchQuery
97
     */
98
    public function setActorInstitution($actorInstitution)
99
    {
100
        $this->assertNonEmptyString($actorInstitution, 'actorInstitution');
101
102
        $this->actorInstitution = $actorInstitution;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @param string $institution
109
     * @return VerifiedSecondFactorSearchQuery
110
     */
111
    public function setInstitution($institution)
112
    {
113
        $this->assertNonEmptyString($institution, 'institution');
114
115
        $this->institution = $institution;
116
117
        return $this;
118
    }
119
120
    /**
121
     * @param string $actorInstitution
0 ignored issues
show
Bug introduced by
There is no parameter named $actorInstitution. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
122
     * @return VerifiedSecondFactorSearchQuery
123
     */
124
    public function setActorId($actorId)
125
    {
126
        $this->assertNonEmptyString($actorId, 'actorId');
127
128
        $this->actorId = $actorId;
129
130
        return $this;
131
    }
132
133 View Code Duplication
    private function assertNonEmptyString($value, $name)
0 ignored issues
show
Duplication introduced by
This method 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...
134
    {
135
        $message = sprintf(
136
            '"%s" must be a non-empty string, "%s" given',
137
            $name,
138
            (is_object($value) ? get_class($value) : gettype($value))
139
        );
140
141
        Assert\that($value)->string($message)->notEmpty($message);
142
    }
143
144
    public function toHttpQuery()
145
    {
146
        $fields = [];
147
148
        $fields['actorInstitution'] = $this->actorInstitution;
149
        $fields['institution'] = $this->institution;
150
151
        if ($this->identityId) {
152
            $fields['identityId'] = $this->identityId;
153
        }
154
155
        if ($this->secondFactorId) {
156
            $fields['secondFactorId'] = $this->secondFactorId;
157
        }
158
159
        if ($this->registrationCode) {
160
            $fields['registrationCode'] = $this->registrationCode;
161
        }
162
163
        if ($this->actorId) {
164
            $fields['actorId'] = $this->actorId;
165
        }
166
167
        return '?' . http_build_query($fields);
168
    }
169
}
170