SearchQuery::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 13
cts 13
cp 1
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Werkspot\KvkApi\Http\Search;
6
7
/**
8
 * Class SearchQuery
9
 *
10
 * @author Patrick Development <[email protected]>
11
 */
12
final class SearchQuery implements QueryInterface
13
{
14
    /**
15
     * KvK number, identifying number for a registration in the Netherlands Business Register. Consists of 8 digits
16
     *
17
     * @var string
18
     */
19
    private $kvkNumber;
20
21
    /**
22
     * Branch number (Vestigingsnummer), identifying number of a branch. Consists of 12 digits
23
     *
24
     * @var string
25
     */
26
    private $branchNumber;
27
28
    /**
29
     * RSIN is an identification number for legal entities and partnerships. Consist of only digits
30
     *
31
     * @var int
32
     */
33
    private $rsin;
34
35
    /**
36
     * Street of an address
37
     *
38
     * @var string
39
     */
40
    private $street;
41
42
    /**
43
     * House number of an address
44
     *
45
     * @var string
46
     */
47
    private $houseNumber;
48
49
    /**
50
     * Postal code or ZIP code, example 1000AA
51
     *
52
     * @var string
53
     */
54
    private $postalCode;
55
56
    /**
57
     * City or Town name
58
     *
59
     * @var string
60
     */
61
    private $city;
62
63
    /**
64
     * Indication  to include searching through inactive dossiers/deregistered companies.
65
     * @note History of inactive companies is after 1 January 2012
66
     *
67
     * @var bool
68
     */
69
    private $includeInactiveRegistrations;
70
71
    /**
72
     * restrictToMainBranch Search is restricted to main branches.
73
     *
74
     * @var bool
75
     */
76
    private $restrictToMainBranch;
77
78
    /**
79
     * Defines the search collection for the query
80
     *
81
     * @var string
82
     */
83
    private $site;
84
85
    /**
86
     * User can optionally add a context to identify his result later on
87
     *
88
     * @var string
89
     */
90
    private $context;
91
92
    /**
93
     * Free format text search for in the compiled search description.
94
     *
95
     * @var string
96
     */
97
    private $freeTextQuery;
98
99 70
    public function getStreet(): ?string
100
    {
101 70
        return $this->street;
102
    }
103
104 5
    public function setStreet(string $street): SearchQuery
105
    {
106 5
        $this->street = $street;
107
108 5
        return $this;
109
    }
110
111 70
    public function getHouseNumber(): ?string
112
    {
113 70
        return $this->houseNumber;
114
    }
115
116 5
    public function setHouseNumber(string $houseNumber): SearchQuery
117
    {
118 5
        $this->houseNumber = $houseNumber;
119
120 5
        return $this;
121
    }
122
123 70
    public function getKvkNumber(): ?string
124
    {
125 70
        return $this->kvkNumber;
126
    }
127
128 21
    public function setKvkNumber(string $kvkNumber): SearchQuery
129
    {
130 21
        $this->kvkNumber = $kvkNumber;
131
132 21
        return $this;
133
    }
134
135 70
    public function getBranchNumber(): ?string
136
    {
137 70
        return $this->branchNumber;
138
    }
139
140 5
    public function setBranchNumber(string $branchNumber): SearchQuery
141
    {
142 5
        $this->branchNumber = $branchNumber;
143
144 5
        return $this;
145
    }
146
147 70
    public function getRsin(): ?int
148
    {
149 70
        return $this->rsin;
150
    }
151
152 5
    public function setRsin(int $rsin): SearchQuery
153
    {
154 5
        $this->rsin = $rsin;
155
156 5
        return $this;
157
    }
158
159 70
    public function getPostalCode(): ?string
160
    {
161 70
        return $this->postalCode;
162
    }
163
164 5
    public function setPostalCode(string $postalCode): SearchQuery
165
    {
166 5
        $this->postalCode = $postalCode;
167
168 5
        return $this;
169
    }
170
171 70
    public function getCity(): ?string
172
    {
173 70
        return $this->city;
174
    }
175
176 5
    public function setCity(string $city): SearchQuery
177
    {
178 5
        $this->city = $city;
179
180 5
        return $this;
181
    }
182
183 70
    public function isIncludeInactiveRegistrations(): ?bool
184
    {
185 70
        return $this->includeInactiveRegistrations;
186
    }
187
188 2
    public function setIncludeInactiveRegistrations(bool $includeInactiveRegistrations): SearchQuery
189
    {
190 2
        $this->includeInactiveRegistrations = $includeInactiveRegistrations;
191
192 2
        return $this;
193
    }
194
195 70
    public function isRestrictToMainBranch(): ?bool
196
    {
197 70
        return $this->restrictToMainBranch;
198
    }
199
200 2
    public function setRestrictToMainBranch(bool $restrictToMainBranch): SearchQuery
201
    {
202 2
        $this->restrictToMainBranch = $restrictToMainBranch;
203
204 2
        return $this;
205
    }
206
207 70
    public function getSite(): ?string
208
    {
209 70
        return $this->site;
210
    }
211
212 5
    public function setSite(string $site): SearchQuery
213
    {
214 5
        $this->site = $site;
215
216 5
        return $this;
217
    }
218
219 70
    public function getContext(): ?string
220
    {
221 70
        return $this->context;
222
    }
223
224 5
    public function setContext(string $context): SearchQuery
225
    {
226 5
        $this->context = $context;
227
228 5
        return $this;
229
    }
230
231 70
    public function getFreeTextQuery(): ?string
232
    {
233 70
        return $this->freeTextQuery;
234
    }
235
236 5
    public function setFreeTextQuery(string $freeTextQuery): SearchQuery
237
    {
238 5
        $this->freeTextQuery = $freeTextQuery;
239
240 5
        return $this;
241
    }
242
243 70
    public function get(): array
244
    {
245
        return [
246 70
            'kvkNumber' => $this->getKvkNumber(),
247 70
            'branchNumber' => $this->getBranchNumber(),
248 70
            'rsin' => $this->getRsin(),
249 70
            'street' => $this->getStreet(),
250 70
            'houseNumber' => $this->getHouseNumber(),
251 70
            'postalCode' => $this->getPostalCode(),
252 70
            'city' => $this->getCity(),
253 70
            'includeInactiveRegistrations' => $this->isIncludeInactiveRegistrations(),
254 70
            'restrictToMainBranch' => $this->isRestrictToMainBranch(),
255 70
            'site' => $this->getSite(),
256 70
            'context' => $this->getContext(),
257 70
            'q' => $this->getFreeTextQuery(),
258
        ];
259
    }
260
}
261