Completed
Pull Request — feature/fine-grained-authoriza... (#61)
by Michiel
53:31 queued 33:08
created

VerifiedSecondFactorSearchQuery::setActorId()   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
     * @var string
47
     */
48
    private $actorId;
49
50
    /**
51
     * @param string $identityId
52
     * @return self
53
     */
54
    public function setIdentityId($identityId)
55
    {
56
        $this->assertNonEmptyString($identityId, 'identityId');
57
58
        $this->identityId = $identityId;
59
60
        return $this;
61
    }
62
63
    /**
64
     * @param string $secondFactorId
65
     * @return self
66
     */
67
    public function setSecondFactorId($secondFactorId)
68
    {
69
        $this->assertNonEmptyString($secondFactorId, 'secondFactorId');
70
71
        $this->secondFactorId = $secondFactorId;
72
73
        return $this;
74
    }
75
76
    /**
77
     * @param string $registrationCode
78
     * @return self
79
     */
80
    public function setRegistrationCode($registrationCode)
81
    {
82
        $this->assertNonEmptyString($registrationCode, 'registrationCode');
83
84
        $this->registrationCode = $registrationCode;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @param string $actorInstitution
91
     * @return VerifiedSecondFactorSearchQuery
92
     */
93
    public function setActorInstitution($actorInstitution)
94
    {
95
        $this->assertNonEmptyString($actorInstitution, 'actorInstitution');
96
97
        $this->actorInstitution = $actorInstitution;
98
99
        return $this;
100
    }
101
102
    /**
103
     * @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...
104
     * @return VerifiedSecondFactorSearchQuery
105
     */
106
    public function setActorId($actorId)
107
    {
108
        $this->assertNonEmptyString($actorId, 'actorId');
109
110
        $this->actorId = $actorId;
111
112
        return $this;
113
    }
114
115
    private function assertNonEmptyString($value, $name)
116
    {
117
        $message = sprintf(
118
            '"%s" must be a non-empty string, "%s" given',
119
            $name,
120
            (is_object($value) ? get_class($value) : gettype($value))
121
        );
122
123
        Assert\that($value)->string($message)->notEmpty($message);
124
    }
125
126
    public function toHttpQuery()
127
    {
128
        $fields = [];
129
130
        $fields['actorInstitution'] = $this->actorInstitution;
131
132
        if ($this->identityId) {
133
            $fields['identityId'] = $this->identityId;
134
        }
135
136
        if ($this->secondFactorId) {
137
            $fields['secondFactorId'] = $this->secondFactorId;
138
        }
139
140
        if ($this->registrationCode) {
141
            $fields['registrationCode'] = $this->registrationCode;
142
        }
143
144
        if ($this->actorId) {
145
            $fields['actorId'] = $this->actorId;
146
        }
147
148
        return '?' . http_build_query($fields);
149
    }
150
}
151