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 |
|
|
|
|
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) |
|
|
|
|
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
|
|
|
|
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 methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.