Completed
Push — master ( a53fa0...b35614 )
by Marcin
03:36
created

NativeApi   F

Complexity

Total Complexity 91

Size/Duplication

Total Lines 1205
Duplicated Lines 42.07 %

Test Coverage

Coverage 38.12%

Importance

Changes 0
Metric Value
dl 507
loc 1205
ccs 154
cts 404
cp 0.3812
rs 0.6314
c 0
b 0
f 0
wmc 91

56 Methods

Rating   Name   Duplication   Size   Complexity  
A PobierzDateAktualnegoKatUlic() 8 8 2
A getInstance() 0 7 2
A __construct() 0 3 1
A create() 0 5 1
A CzyZalogowany() 0 5 1
A WeryfikujAdresDlaMiejscowosci() 6 6 1
A PobierzListeUlicDlaMiejscowosci() 0 20 2
A PobierzZmianyUlicUrzedowy() 14 14 1
A WeryfikujAdresDlaMiejscowosciAdresowy() 6 6 1
A PobierzKatalogTERC() 7 7 1
A PobierzDateAktualnegoKatNTS() 8 8 2
A PobierzListeRegionow() 0 9 2
A WyszukajMiejscowosc() 10 10 2
A PobierzListeGmin() 0 9 2
B WeryfikujNazwaAdresUlicAdresowy() 26 26 2
A PobierzZmianySimcUrzedowy() 14 14 1
B WeryfikujNazwaAdresUlic() 26 26 2
A PobierzSlownikRodzajowSIMC() 0 9 2
A PobierzZmianyTercAdresowy() 14 14 1
A PobierzKatalogTERCAdr() 7 7 1
A WeryfikujAdresDlaUlic() 6 6 1
A PobierzListeWojewodztw() 0 9 2
A PobierzKatalogULICBezDzielnic() 7 7 1
A PobierzKatalogWMRODZ() 7 7 1
A PobierzDateAktualnegoKatSimc() 8 8 2
A PobierzZmianyUlicAdresowy() 14 14 1
A PobierzKatalogULICAdr() 7 7 1
A WeryfikujAdresWmiejscowosci() 21 21 2
B WyszukajJednostkeWRejestrze() 25 25 4
A PobierzListePodregionow() 0 9 2
A PobierzSlownikRodzajowJednostek() 0 5 1
A WyszukajUlice() 14 14 2
A PobierzZmianyNTS() 14 14 1
A PobierzZmianyTercUrzedowy() 14 14 1
A PobierzZmianySimcStatystyczny() 14 14 1
A PobierzListeMiejscowosciWGminie() 0 14 2
A PobierzGminyiPowDlaWoj() 0 9 2
A PobierzListeGminPowiecie() 0 9 2
A PobierzListeWojewodztwWRegionie() 0 9 2
A WeryfikujAdresDlaUlicAdresowy() 6 6 1
A PobierzListeMiejscowosciWRodzajuGminy() 0 16 2
A PobierzListePowiatow() 0 9 2
A PobierzKatalogSIMCAdr() 7 7 1
A PobierzKatalogNTS() 7 7 1
A WyszukajJPT() 9 9 2
B WyszukajMiejscowoscWRejestrze() 27 27 4
A PobierzKatalogSIMCStat() 7 7 1
A PobierzSlownikCechULIC() 0 5 1
A PobierzZmianySimcAdresowy() 14 14 1
A PobierzDateAktualnegoKatTerc() 8 8 2
A WeryfikujAdresWmiejscowosciAdresowy() 21 21 2
A PobierzKatalogSIMC() 7 7 1
A PobierzListePowiatowWPodregionie() 0 9 2
B WyszukajMiejscowoscWJPT() 24 24 2
A PobierzKatalogULIC() 7 7 1
B WyszukajUliceWRejestrze() 27 27 4

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like NativeApi often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use NativeApi, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * TERYT-API
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 *
14
 */
15
16
/**
17
 * Created by Marcin.
18
 * Date: 11.09.2017
19
 * Time: 23:01
20
 */
21
22
namespace mrcnpdlk\Teryt;
23
24
use mrcnpdlk\Teryt\Model\Terc;
25
use mrcnpdlk\Teryt\ResponseModel\Dictionary\RodzajMiejscowosci;
26
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaNomenklaturyNTS;
27
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaPodzialuTerytorialnego;
28
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaTerytorialna;
29
use mrcnpdlk\Teryt\ResponseModel\Territory\Miejscowosc;
30
use mrcnpdlk\Teryt\ResponseModel\Territory\Ulica;
31
use mrcnpdlk\Teryt\ResponseModel\Territory\UlicaDrzewo;
32
use mrcnpdlk\Teryt\ResponseModel\Territory\WyszukanaMiejscowosc;
33
use mrcnpdlk\Teryt\ResponseModel\Territory\WyszukanaUlica;
34
use mrcnpdlk\Teryt\ResponseModel\Territory\ZweryfikowanyAdres;
35
use mrcnpdlk\Teryt\ResponseModel\Territory\ZweryfikowanyAdresBezUlic;
36
37
38
final class NativeApi
39
{
40
    /**
41
     * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
42
     */
43
    const CATEGORY_ALL         = '0'; // Wyszukiwanie wśród wszystkich rodzajów jednostek
44
    const CATEGORY_WOJ_ALL     = '1'; // Dla województw
45
    const CATEGORY_POW_ALL     = '2'; // Dla wszystkich powiatów
46
    const CATEGORY_POW_ZIE     = '21'; // Dla powiatów ziemskich (identyfikator powiatu 01-60)
47
    const CATEGORY_POW_MIA     = '22'; // Dla miast na prawach powiatu (identyfikator powiatu 61-99)
48
    const CATEGORY_GMI_ALL     = '3'; // Dla gmin ogółem
49
    const CATEGORY_GMI_MIA     = '31'; // Dla gmin miejskich (identyfikator rodzaju gminy 1)
50
    const CATEGORY_DELEG       = '32'; // Dla dzielnic i delegatur (identyfikator rodzaju 8 i 9)
51
    const CATEGORY_GMI_WIE     = '33'; // Dla gmin wiejskich (identyfikator rodzaju 2)
52
    const CATEGORY_GMI_MIE_WIE = '34'; // Dla gmin miejsko-wiejskich (3)
53
    const CATEGORY_MIA         = '341'; // Dla miast w gminach miejsko-wiejskich(4)
54
    const CATEGORY_MIA_OBS     = '342'; // Dla obszarów miejskich w gminach miejsko-wiejskich(5)
55
    const CATEGORY_MIA_ALL     = '35'; // Dla miast ogółem (identyfikator 1 i 4)
56
    const CATEGORY_WIE         = '36'; // Dla terenów wiejskich (identyfikator 2 i 5)
57
58
    /**
59
     * Określenie zakresu miejscowości
60
     */
61
62
    const SEARCH_CITY_TYPE_ALL  = '000'; //Wszystkie
63
    const SEARCH_CITY_TYPE_MAIN = '001'; //Miejscowości podstawowe
64
    const SEARCH_CITY_TYPE_ADD  = '002'; //Części integralne miejscowości
65
66
    /**
67
     * @var \mrcnpdlk\Teryt\NativeApi|null
68
     */
69
    protected static $instance = null;
70
    /**
71
     * @var Client
72
     */
73
    protected $oClient;
74
75
    /**
76
     * NativeApi constructor.
77
     *
78
     * @param \mrcnpdlk\Teryt\Client $oClient
79
     */
80 11
    protected function __construct(Client $oClient)
81
    {
82 11
        $this->oClient = $oClient;
83 11
    }
84
85
    /**
86
     * @param \mrcnpdlk\Teryt\Client $oClient
87
     *
88
     * @return \mrcnpdlk\Teryt\NativeApi
89
     */
90 11
    public static function create(Client $oClient): NativeApi
91
    {
92 11
        static::$instance = new static($oClient);
93
94 11
        return static::$instance;
95
    }
96
97
    /**
98
     * @return \mrcnpdlk\Teryt\NativeApi
99
     * @throws \mrcnpdlk\Teryt\Exception
100
     */
101 2
    public static function getInstance(): NativeApi
102
    {
103 2
        if (!isset(static::$instance)) {
104
            throw new Exception(sprintf('First call CREATE method!'));
105
        }
106
107 2
        return static::$instance;
108
    }
109
110
    /**
111
     * Sprawdzenie czy użytkownik jest zalogowany
112
     *
113
     * @return bool
114
     */
115 1
    public function CzyZalogowany(): bool
116
    {
117 1
        $res = $this->oClient->request('CzyZalogowany');
118
119 1
        return $res;
120
    }
121
122
    /**
123
     * Data początkowa bieżącego stanu katalogu NTS
124
     *
125
     * @return null|string Data w formacie YYY-MM-DD
126
     */
127 View Code Duplication
    public function PobierzDateAktualnegoKatNTS()
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...
128
    {
129
        $res = $this->oClient->request('PobierzDateAktualnegoKatNTS');
130
131
        try {
132
            return (new \DateTime($res))->format('Y-m-d');
133
        } catch (\Exception $e) {
134
            return null;
135
        }
136
    }
137
138
    /**
139
     * Data początkowa bieżącego stanu katalogu SIMC
140
     *
141
     * @return null|string Data w formacie YYY-MM-DD
142
     */
143 View Code Duplication
    public function PobierzDateAktualnegoKatSimc()
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...
144
    {
145
        $res = $this->oClient->request('PobierzDateAktualnegoKatSimc');
146
147
        try {
148
            return (new \DateTime($res))->format('Y-m-d');
149
        } catch (\Exception $e) {
150
            return null;
151
        }
152
    }
153
154
    /**
155
     * Data początkowa bieżącego stanu katalogu TERC
156
     *
157
     * @return null|string Data w formacie YYY-MM-DD
158
     */
159 View Code Duplication
    public function PobierzDateAktualnegoKatTerc()
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...
160
    {
161
        $res = $this->oClient->request('PobierzDateAktualnegoKatTerc');
162
163
        try {
164
            return (new \DateTime($res))->format('Y-m-d');
165
        } catch (\Exception $e) {
166
            return null;
167
        }
168
    }
169
170
    /**
171
     * Data początkowa bieżącego stanu katalogu ULIC
172
     *
173
     * @return null|string Data w formacie YYY-MM-DD
174
     */
175 View Code Duplication
    public function PobierzDateAktualnegoKatUlic()
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...
176
    {
177
        $res = $this->oClient->request('PobierzDateAktualnegoKatUlic');
178
179
        try {
180
            return (new \DateTime($res))->format('Y-m-d');
181
        } catch (\Exception $e) {
182
            return null;
183
        }
184
    }
185
186
    /**
187
     * Lista powiatów i gmin we wskazanym województwie
188
     *
189
     * @param string $provinceId
190
     *
191
     * @return JednostkaTerytorialna[]
192
     */
193 1
    public function PobierzGminyiPowDlaWoj(string $provinceId)
194
    {
195 1
        $answer = [];
196 1
        $res    = $this->oClient->request('PobierzGminyiPowDlaWoj', ['Woj' => $provinceId]);
197 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
198 1
            $answer[] = new JednostkaTerytorialna($p);
199
        };
200
201 1
        return $answer;
202
    }
203
204
    /**
205
     * Identyfikatory i nazwy jednostek nomenklatury z wybranego stanu katalogu
206
     *
207
     * @return \SplFileObject
208
     */
209 View Code Duplication
    public function PobierzKatalogNTS(): \SplFileObject
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...
210
    {
211
        $res     = $this->oClient->request('PobierzKatalogNTS');
212
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
213
        $content = base64_decode($res->plik_zawartosc);
214
215
        return Helper::saveFile($sPath, $content);
216
    }
217
218
    /**
219
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
220
     *
221
     * @return \SplFileObject
222
     */
223 View Code Duplication
    public function PobierzKatalogSIMC(): \SplFileObject
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...
224
    {
225
        $res     = $this->oClient->request('PobierzKatalogSIMC');
226
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
227
        $content = base64_decode($res->plik_zawartosc);
228
229
        return Helper::saveFile($sPath, $content);
230
    }
231
232
    /**
233
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
234
     *
235
     * @return \SplFileObject
236
     */
237 View Code Duplication
    public function PobierzKatalogSIMCAdr(): \SplFileObject
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...
238
    {
239
        $res     = $this->oClient->request('PobierzKatalogSIMCAdr');
240
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
241
        $content = base64_decode($res->plik_zawartosc);
242
243
        return Helper::saveFile($sPath, $content);
244
    }
245
246
    /**
247
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
248
     *
249
     * @return \SplFileObject
250
     */
251 View Code Duplication
    public function PobierzKatalogSIMCStat(): \SplFileObject
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...
252
    {
253
        $res     = $this->oClient->request('PobierzKatalogSIMCStat');
254
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
255
        $content = base64_decode($res->plik_zawartosc);
256
257
        return Helper::saveFile($sPath, $content);
258
    }
259
260
    /**
261
     * Dane z systemu identyfikatorów TERC z wybranego stanu katalogu w wersji urzędowej
262
     *
263
     * @return \SplFileObject
264
     */
265 View Code Duplication
    public function PobierzKatalogTERC(): \SplFileObject
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...
266
    {
267
        $res     = $this->oClient->request('PobierzKatalogTERC');
268
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
269
        $content = base64_decode($res->plik_zawartosc);
270
271
        return Helper::saveFile($sPath, $content);
272
    }
273
274
    /**
275
     * Dane z systemu identyfikatorów TERC z wybranego stanu katalogu w wersji adresowej
276
     *
277
     * @return \SplFileObject
278
     */
279 View Code Duplication
    public function PobierzKatalogTERCAdr(): \SplFileObject
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...
280
    {
281
        $res     = $this->oClient->request('PobierzKatalogTERCAdr');
282
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
283
        $content = base64_decode($res->plik_zawartosc);
284
285
        return Helper::saveFile($sPath, $content);
286
    }
287
288
    /**
289
     * Katalog ulic dla wskazanego stanu w wersji urzędowej
290
     *
291
     * @return \SplFileObject
292
     */
293 View Code Duplication
    public function PobierzKatalogULIC(): \SplFileObject
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...
294
    {
295
        $res     = $this->oClient->request('PobierzKatalogULIC');
296
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
297
        $content = base64_decode($res->plik_zawartosc);
298
299
        return Helper::saveFile($sPath, $content);
300
    }
301
302
    /**
303
     * Katalog ulic dla wskazanego stanu w wersji adresowej
304
     *
305
     * @return \SplFileObject
306
     */
307 View Code Duplication
    public function PobierzKatalogULICAdr(): \SplFileObject
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...
308
    {
309
        $res     = $this->oClient->request('PobierzKatalogULICAdr');
310
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
311
        $content = base64_decode($res->plik_zawartosc);
312
313
        return Helper::saveFile($sPath, $content);
314
    }
315
316
    /**
317
     * Katalog ulic dla wskazanego stanu w wersji urzędowej zmodyfikowany dla miast posiadający delegatury
318
     *
319
     * @return \SplFileObject
320
     */
321 View Code Duplication
    public function PobierzKatalogULICBezDzielnic(): \SplFileObject
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...
322
    {
323
        $res     = $this->oClient->request('PobierzKatalogULICBezDzielnic');
324
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
325
        $content = base64_decode($res->plik_zawartosc);
326
327
        return Helper::saveFile($sPath, $content);
328
    }
329
330
    /**
331
     * Katalog rodzajów miejscowości dla wskazanego stanu
332
     *
333
     * @return \SplFileObject
334
     */
335 1 View Code Duplication
    public function PobierzKatalogWMRODZ(): \SplFileObject
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...
336
    {
337 1
        $res     = $this->oClient->request('PobierzKatalogWMRODZ');
338 1
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
339 1
        $content = base64_decode($res->plik_zawartosc);
340
341 1
        return Helper::saveFile($sPath, $content);
342
    }
343
344
    /**
345
     * Lista gmin we wskazanym powiecie
346
     *
347
     * @param string $provinceId
348
     * @param string $districtId
349
     *
350
     * @return JednostkaTerytorialna[]
351
     */
352 1
    public function PobierzListeGmin(string $provinceId, string $districtId)
353
    {
354 1
        $answer = [];
355 1
        $res    = $this->oClient->request('PobierzListeGmin', ['Woj' => $provinceId, 'Pow' => $districtId]);
356 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
357 1
            $answer[] = new JednostkaTerytorialna($p);
358
        };
359
360 1
        return $answer;
361
    }
362
363
    /**
364
     * Lista gmin w powiecie
365
     *
366
     * @param string $districtId  dwuznakowy symbol powiatu
367
     * @param string $subregionId dwuznakowy symbol podregionu
368
     *
369
     * @return JednostkaNomenklaturyNTS[]
370
     */
371 1
    public function PobierzListeGminPowiecie(string $districtId, string $subregionId)
372
    {
373 1
        $answer = [];
374 1
        $res    = $this->oClient->request('PobierzListeGminPowiecie', ['Pow' => $districtId, 'Podreg' => $subregionId]);
375 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
376 1
            $answer[] = new JednostkaNomenklaturyNTS($p);
377
        };
378
379 1
        return $answer;
380
    }
381
382
    /**
383
     * Lista miejscowości znajdujących się we wskazanej gminie.
384
     * Wyszukiwanie odbywa się z uwzględnieniem nazw
385
     *
386
     * @param string $provinceName
387
     * @param string $districtName
388
     * @param string $communeName
389
     *
390
     * @return Miejscowosc[]
391
     */
392
    public function PobierzListeMiejscowosciWGminie(string $provinceName, string $districtName, string $communeName)
393
    {
394
        $answer = [];
395
        $res    = $this->oClient->request('PobierzListeMiejscowosciWGminie',
396
            [
397
                'Wojewodztwo' => $provinceName,
398
                'Powiat'      => $districtName,
399
                'Gmina'       => $communeName,
400
            ]);
401
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
402
            $answer[] = new Miejscowosc($p);
403
        };
404
405
        return $answer;
406
    }
407
408
    /**
409
     * Lista miejscowości znajdujących się we wskazanej gminie.
410
     * Wyszukiwanie odbywa się z uwzględnieniem symboli
411
     *
412
     * @param int $tercId
413
     *
414
     * @return Miejscowosc[]
415
     */
416
    public function PobierzListeMiejscowosciWRodzajuGminy(int $tercId)
417
    {
418
        $answer = [];
419
        $oTerc  = new Terc($tercId);
420
        $res    = $this->oClient->request('PobierzListeMiejscowosciWRodzajuGminy',
421
            [
422
                'symbolWoj'  => $oTerc->getProvinceId(),
423
                'symbolPow'  => $oTerc->getDistrictId(),
424
                'symbolGmi'  => $oTerc->getCommuneId(),
425
                'symbolRodz' => $oTerc->getCommuneTypeId(),
426
            ]);
427
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
428
            $answer[] = new Miejscowosc($p);
429
        };
430
431
        return $answer;
432
    }
433
434
    /**
435
     * Lista podregionów w województwie
436
     *
437
     * @param string $provinceId Dwuznakowy symbol województwa
438
     *
439
     * @return JednostkaNomenklaturyNTS[]
440
     */
441 1
    public function PobierzListePodregionow(string $provinceId)
442
    {
443 1
        $answer = [];
444 1
        $res    = $this->oClient->request('PobierzListePodregionow', ['Woj' => $provinceId]);
445 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
446 1
            $answer[] = new JednostkaNomenklaturyNTS($p);
447
        };
448
449 1
        return $answer;
450
    }
451
452
    /**
453
     * Pobieranie listy powiatów dla danego województwa
454
     *
455
     * @param string $provinceId
456
     *
457
     * @return JednostkaTerytorialna[]
458
     */
459 2
    public function PobierzListePowiatow(string $provinceId)
460
    {
461 2
        $answer = [];
462 2
        $res    = $this->oClient->request('PobierzListePowiatow', ['Woj' => $provinceId]);
463 2
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
464 2
            $answer[] = new JednostkaTerytorialna($p);
465
        };
466
467 2
        return $answer;
468
    }
469
470
    /**
471
     * Lista powiatów w podregionie
472
     *
473
     * @param string $subregionId Dwuznakowy symbol podregionu
474
     *
475
     * @return JednostkaNomenklaturyNTS[]
476
     */
477 1
    public function PobierzListePowiatowWPodregionie(string $subregionId)
478
    {
479 1
        $answer = [];
480 1
        $res    = $this->oClient->request('PobierzListePowiatowWPodregionie', ['Podreg' => $subregionId]);
481 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
482 1
            $answer[] = new JednostkaNomenklaturyNTS($p);
483
        };
484
485 1
        return $answer;
486
    }
487
488
    /**
489
     * Lista regionów
490
     *
491
     * @return JednostkaNomenklaturyNTS[]
492
     */
493 1
    public function PobierzListeRegionow()
494
    {
495 1
        $answer = [];
496 1
        $res    = $this->oClient->request('PobierzListeRegionow');
497 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
498 1
            $answer[] = new JednostkaNomenklaturyNTS($p);
499
        };
500
501 1
        return $answer;
502
    }
503
504
    /**
505
     * Lista ulic we wskazanej miejscowości
506
     *
507
     * @param int    $tercId
508
     * @param string $cityId
509
     * @param bool   $asAddress
510
     *
511
     * @return UlicaDrzewo[]
512
     */
513
    public function PobierzListeUlicDlaMiejscowosci(int $tercId, string $cityId, bool $asAddress = false)
514
    {
515
        $answer = [];
516
        $oTerc  = new Terc($tercId);
517
        $res    = $this->oClient->request('PobierzListeUlicDlaMiejscowosci',
518
            [
519
                'woj'               => $oTerc->getProvinceId(),
520
                'pow'               => $oTerc->getDistrictId(),
521
                'gmi'               => $oTerc->getCommuneId(),
522
                'rodzaj'            => $oTerc->getCommuneTypeId(),
523
                'msc'               => $cityId,
524
                'czyWersjaUrzedowa' => !$asAddress,
525
                'czyWersjaAdresowa' => $asAddress,
526
            ]
527
        );
528
        foreach (Helper::getPropertyAsArray($res, 'UlicaDrzewo') as $p) {
529
            $answer[] = new UlicaDrzewo($p);
530
        };
531
532
        return $answer;
533
    }
534
535
    /**
536
     * Lista województw
537
     *
538
     * @return JednostkaTerytorialna[]
539
     */
540 4
    public function PobierzListeWojewodztw()
541
    {
542 4
        $answer = [];
543 4
        $res    = $this->oClient->request('PobierzListeWojewodztw');
544 3
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
545 3
            $answer[] = new JednostkaTerytorialna($p);
546
        };
547
548 3
        return $answer;
549
    }
550
551
    /**
552
     * Lista województw regionie
553
     *
554
     * @param string $regionId Jednoznakowy symbol regionu
555
     *
556
     * @return JednostkaNomenklaturyNTS[]
557
     */
558 1
    public function PobierzListeWojewodztwWRegionie(string $regionId)
559
    {
560 1
        $answer = [];
561 1
        $res    = $this->oClient->request('PobierzListeWojewodztwWRegionie', ['Reg' => $regionId]);
562 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
563 1
            $answer[] = new JednostkaNomenklaturyNTS($p);
564
        };
565
566 1
        return $answer;
567
    }
568
569
    /**
570
     * Zwraca listę cech obiektów z katalogu ulic
571
     *
572
     * @return string[]
573
     */
574 1
    public function PobierzSlownikCechULIC()
575
    {
576 1
        $res = $this->oClient->request('PobierzSlownikCechULIC');
577
578 1
        return Helper::getPropertyAsArray($res, 'string');
579
    }
580
581
    /**
582
     * Zwraca listę rodzajów jednostek
583
     *
584
     * @return string[]
585
     */
586
    public function PobierzSlownikRodzajowJednostek()
587
    {
588
        $res = $this->oClient->request('PobierzSlownikRodzajowJednostek');
589
590
        return Helper::getPropertyAsArray($res, 'string');
591
    }
592
593
    /**
594
     * Zwraca listę rodzajów miejscowości
595
     *
596
     * @return RodzajMiejscowosci[]
597
     */
598 1
    public function PobierzSlownikRodzajowSIMC()
599
    {
600 1
        $answer = [];
601 1
        $res    = $this->oClient->request('PobierzSlownikRodzajowSIMC');
602 1
        foreach (Helper::getPropertyAsArray($res, 'RodzajMiejscowosci') as $p) {
603 1
            $answer[] = new RodzajMiejscowosci($p);
604
        };
605
606 1
        return $answer;
607
    }
608
609
    /**
610
     * Zmiany w katalogu TERC w wersji adresowej rejestru
611
     *
612
     * @param \DateTime      $fromDate
613
     * @param \DateTime|null $toDate
614
     *
615
     * @return \SplFileObject
616
     */
617 View Code Duplication
    public function PobierzZmianyNTS(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
618
    {
619
        $toDate  = $toDate ?? new \DateTime();
620
        $res     = $this->oClient->request(
621
            'PobierzZmianyNTS',
622
            [
623
                'stanod' => $fromDate->format('Y-m-d'),
624
                'stando' => $toDate->format('Y-m-d'),
625
            ],
626
            false);
627
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
628
        $content = base64_decode($res->plik_zawartosc);
629
630
        return Helper::saveFile($sPath, $content);
631
    }
632
633
    /**
634
     * Zmiany w katalogu SIMC w wersji adresowej rejestru
635
     *
636
     * @param \DateTime      $fromDate
637
     * @param \DateTime|null $toDate
638
     *
639
     * @return \SplFileObject
640
     */
641 View Code Duplication
    public function PobierzZmianySimcAdresowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
642
    {
643
        $toDate  = $toDate ?? new \DateTime();
644
        $res     = $this->oClient->request(
645
            'PobierzZmianySimcAdresowy',
646
            [
647
                'stanod' => $fromDate->format('Y-m-d'),
648
                'stando' => $toDate->format('Y-m-d'),
649
            ],
650
            false);
651
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
652
        $content = base64_decode($res->plik_zawartosc);
653
654
        return Helper::saveFile($sPath, $content);
655
    }
656
657
    /**
658
     * Zmiany w katalogu SIMC w wersji statystycznej rejestru
659
     *
660
     * @param \DateTime      $fromDate
661
     * @param \DateTime|null $toDate
662
     *
663
     * @return \SplFileObject
664
     */
665 View Code Duplication
    public function PobierzZmianySimcStatystyczny(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
666
    {
667
        $toDate  = $toDate ?? new \DateTime();
668
        $res     = $this->oClient->request(
669
            'PobierzZmianySimcStatystyczny',
670
            [
671
                'stanod' => $fromDate->format('Y-m-d'),
672
                'stando' => $toDate->format('Y-m-d'),
673
            ],
674
            false);
675
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
676
        $content = base64_decode($res->plik_zawartosc);
677
678
        return Helper::saveFile($sPath, $content);
679
    }
680
681
    /**
682
     * Zmiany w katalogu SIMC w wersji urzędowej rejestru
683
     *
684
     * @param \DateTime      $fromDate
685
     * @param \DateTime|null $toDate
686
     *
687
     * @return \SplFileObject
688
     */
689 View Code Duplication
    public function PobierzZmianySimcUrzedowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
690
    {
691
        $toDate  = $toDate ?? new \DateTime();
692
        $res     = $this->oClient->request(
693
            'PobierzZmianySimcUrzedowy',
694
            [
695
                'stanod' => $fromDate->format('Y-m-d'),
696
                'stando' => $toDate->format('Y-m-d'),
697
            ],
698
            false);
699
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
700
        $content = base64_decode($res->plik_zawartosc);
701
702
        return Helper::saveFile($sPath, $content);
703
    }
704
705
    /**
706
     * Zmiany w katalogu TERC w wersji adresowej rejestru
707
     *
708
     * @param \DateTime      $fromDate
709
     * @param \DateTime|null $toDate
710
     *
711
     * @return \SplFileObject
712
     */
713 1 View Code Duplication
    public function PobierzZmianyTercAdresowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
714
    {
715 1
        $toDate  = $toDate ?? new \DateTime();
716 1
        $res     = $this->oClient->request(
717 1
            'PobierzZmianyTercAdresowy',
718
            [
719 1
                'stanod' => $fromDate->format('Y-m-d'),
720 1
                'stando' => $toDate->format('Y-m-d'),
721
            ],
722 1
            false);
723 1
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
724 1
        $content = base64_decode($res->plik_zawartosc);
725
726 1
        return Helper::saveFile($sPath, $content);
727
    }
728
729
    /**
730
     * Zmiany w katalogu TERC w wersji urzędowej rejestru
731
     *
732
     * @param \DateTime      $fromDate
733
     * @param \DateTime|null $toDate
734
     *
735
     * @return \SplFileObject
736
     */
737 View Code Duplication
    public function PobierzZmianyTercUrzedowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
738
    {
739
        $toDate  = $toDate ?? new \DateTime();
740
        $res     = $this->oClient->request(
741
            'PobierzZmianyTercUrzedowy',
742
            [
743
                'stanod' => $fromDate->format('Y-m-d'),
744
                'stando' => $toDate->format('Y-m-d'),
745
            ],
746
            false);
747
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
748
        $content = base64_decode($res->plik_zawartosc);
749
750
        return Helper::saveFile($sPath, $content);
751
    }
752
753
    /**
754
     * Zmiany w katalogu ULIC w wersji adresowej rejestru
755
     *
756
     * @param \DateTime      $fromDate
757
     * @param \DateTime|null $toDate
758
     *
759
     * @return \SplFileObject
760
     */
761 View Code Duplication
    public function PobierzZmianyUlicAdresowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
762
    {
763
        $toDate  = $toDate ?? new \DateTime();
764
        $res     = $this->oClient->request(
765
            'PobierzZmianyUlicAdresowy',
766
            [
767
                'stanod' => $fromDate->format('Y-m-d'),
768
                'stando' => $toDate->format('Y-m-d'),
769
            ],
770
            false);
771
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
772
        $content = base64_decode($res->plik_zawartosc);
773
774
        return Helper::saveFile($sPath, $content);
775
    }
776
777
    /**
778
     * Zmiany w katalogu ULIC w wersji urzędowej rejestru
779
     *
780
     * @param \DateTime      $fromDate
781
     * @param \DateTime|null $toDate
782
     *
783
     * @return \SplFileObject
784
     */
785 View Code Duplication
    public function PobierzZmianyUlicUrzedowy(\DateTime $fromDate, \DateTime $toDate = null): \SplFileObject
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...
786
    {
787
        $toDate  = $toDate ?? new \DateTime();
788
        $res     = $this->oClient->request(
789
            'PobierzZmianyUlicUrzedowy',
790
            [
791
                'stanod' => $fromDate->format('Y-m-d'),
792
                'stando' => $toDate->format('Y-m-d'),
793
            ],
794
            false);
795
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
796
        $content = base64_decode($res->plik_zawartosc);
797
798
        return Helper::saveFile($sPath, $content);
799
    }
800
801
    /**
802
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
803
     * miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
804
     *
805
     * @param string $cityId
806
     *
807
     * @return ZweryfikowanyAdresBezUlic
808
     */
809 1 View Code Duplication
    public function WeryfikujAdresDlaMiejscowosci(string $cityId)
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...
810
    {
811 1
        $res   = $this->oClient->request('WeryfikujAdresDlaMiejscowosci', ['symbolMsc' => $cityId]);
812 1
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
813
814 1
        return new ZweryfikowanyAdresBezUlic($oData);
815
    }
816
817
    /**
818
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT,w wersji
819
     * adresowej rejestru do poziomu miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
820
     *
821
     * @param string $cityId
822
     *
823
     * @return ZweryfikowanyAdresBezUlic
824
     */
825 1 View Code Duplication
    public function WeryfikujAdresDlaMiejscowosciAdresowy(string $cityId)
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...
826
    {
827 1
        $res   = $this->oClient->request('WeryfikujAdresDlaMiejscowosciAdresowy', ['symbolMsc' => $cityId]);
828 1
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
829
830 1
        return new ZweryfikowanyAdresBezUlic($oData);
831
    }
832
833
    /**
834
     * Weryfikuje istnienie wskazanego obiektu w bazie
835
     * TERYT do poziomu ulic.Weryfikacja odbywa się za pomoca nazw
836
     *
837
     * @param string $cityId
838
     * @param string $streetId
839
     *
840
     * @return ZweryfikowanyAdres
841
     */
842 1 View Code Duplication
    public function WeryfikujAdresDlaUlic(string $cityId, string $streetId): ZweryfikowanyAdres
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...
843
    {
844 1
        $res   = $this->oClient->request('WeryfikujAdresDlaUlic', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
845 1
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
846
847 1
        return new ZweryfikowanyAdres($oData);
848
    }
849
850
    /**
851
     * Weryfikuje istnienie wskazanego obiektu w bazie
852
     * TERYT do poziomu ulic w wersji adresowej. Weryfikacja odbywa się za pomoca nazw
853
     *
854
     * @param string $cityId
855
     * @param string $streetId
856
     *
857
     * @return ZweryfikowanyAdres
858
     */
859 1 View Code Duplication
    public function WeryfikujAdresDlaUlicAdresowy(string $cityId, string $streetId): ZweryfikowanyAdres
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...
860
    {
861 1
        $res   = $this->oClient->request('WeryfikujAdresDlaUlicAdresowy', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
862 1
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
863
864 1
        return new ZweryfikowanyAdres($oData);
865
    }
866
867
    /**
868
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
869
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
870
     *
871
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
872
     * w wtórym zostanie zwrócona tablica wyników
873
     *
874
     * @param string      $provinceName Nazwa województwa
875
     * @param string      $districtName Nazwa powiatu
876
     * @param string      $communeName  Nazwa gminy
877
     * @param string      $cityName     Nazwa miejscowości
878
     * @param string|null $cityTypeName Nazwa typu miejscowości
879
     *
880
     * @return ZweryfikowanyAdresBezUlic[]
881
     */
882 1 View Code Duplication
    public function WeryfikujAdresWmiejscowosci(
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...
883
        string $provinceName,
884
        string $districtName,
885
        string $communeName,
886
        string $cityName,
887
        string $cityTypeName = null
888
    ): array {
889 1
        $answer = [];
890 1
        $res    = $this->oClient->request('WeryfikujAdresWmiejscowosci',
891
            [
892 1
                'Wojewodztwo' => $provinceName,
893 1
                'Powiat'      => $districtName,
894 1
                'Gmina'       => $communeName,
895 1
                'Miejscowosc' => $cityName,
896 1
                'Rodzaj'      => $cityTypeName,
897
            ]);
898 1
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
899 1
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
900
        };
901
902 1
        return $answer;
903
    }
904
905
    /**
906
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT w wersji adresowej do poziomu
907
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
908
     *
909
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
910
     * w wtórym zostanie zwrócona tablica wyników
911
     *
912
     * @param string      $provinceName Nazwa województwa
913
     * @param string      $districtName Nazwa powiatu
914
     * @param string      $communeName  Nazwa gminy
915
     * @param string      $cityName     Nazwa miejscowości
916
     * @param string|null $cityTypeName Nazwa typu miejscowości
917
     *
918
     * @return ZweryfikowanyAdresBezUlic[]
919
     */
920 1 View Code Duplication
    public function WeryfikujAdresWmiejscowosciAdresowy(
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...
921
        string $provinceName,
922
        string $districtName,
923
        string $communeName,
924
        string $cityName,
925
        string $cityTypeName = null
926
    ): array {
927 1
        $answer = [];
928 1
        $res    = $this->oClient->request('WeryfikujAdresWmiejscowosciAdresowy',
929
            [
930 1
                'Wojewodztwo' => $provinceName,
931 1
                'Powiat'      => $districtName,
932 1
                'Gmina'       => $communeName,
933 1
                'Miejscowosc' => $cityName,
934 1
                'Rodzaj'      => $cityTypeName,
935
            ]);
936 1
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
937 1
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
938
        };
939
940 1
        return $answer;
941
    }
942
943
    /**
944
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu ulic.
945
     * Weryfikacja odbywa się za pomoca nazw
946
     *
947
     * @param string      $provinceName
948
     * @param string      $districtName
949
     * @param string      $communeName
950
     * @param string      $cityName
951
     * @param string|null $cityTypeName
952
     * @param string      $streetName
953
     *
954
     * @return ZweryfikowanyAdres[]
955
     * @todo empty response
956
     */
957 View Code Duplication
    public function WeryfikujNazwaAdresUlic(
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...
958
        string $provinceName,
959
        string $districtName,
960
        string $communeName,
961
        string $cityName,
962
        string $cityTypeName = null,
963
        string $streetName
964
    ) {
965
        $answer = [];
966
        $res    = $this->oClient->request('WeryfikujNazwaAdresUlic',
967
            [
968
                'nazwaWoj'         => $provinceName,
969
                'nazwaPow'         => $districtName,
970
                'nazwaGmi'         => $communeName,
971
                'nazwaMiejscowosc' => $cityName,
972
                'rodzajMiejsc'     => $cityTypeName,
973
                'nazwaUlicy'       => $streetName,
974
            ]);
975
976
        $tData = Helper::getPropertyAsArray($res, 'ZweryfikowanyAdres');
977
978
        foreach ($tData as $datum) {
979
            $answer[] = new ZweryfikowanyAdres($datum);
980
        }
981
982
        return $answer;
983
    }
984
985
    /**
986
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu ulic w wersji adresowej rejestru.
987
     * Weryfikacja odbywa się za pomoca nazw
988
     *
989
     * @param string      $provinceName
990
     * @param string      $districtName
991
     * @param string      $communeName
992
     * @param string      $cityName
993
     * @param string|null $cityTypeName
994
     * @param string      $streetName
995
     *
996
     * @return ZweryfikowanyAdres[]
997
     */
998 View Code Duplication
    public function WeryfikujNazwaAdresUlicAdresowy(
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...
999
        string $provinceName,
1000
        string $districtName,
1001
        string $communeName,
1002
        string $cityName,
1003
        string $cityTypeName = null,
1004
        string $streetName
1005
    ) {
1006
        $answer = [];
1007
        $res    = $this->oClient->request('WeryfikujNazwaAdresUlicAdresowy',
1008
            [
1009
                'nazwaWoj'         => $provinceName,
1010
                'nazwaPow'         => $districtName,
1011
                'nazwaGmi'         => $communeName,
1012
                'nazwaMiejscowosc' => $cityName,
1013
                'rodzajMiejsc'     => $cityTypeName,
1014
                'nazwaUlicy'       => $streetName,
1015
            ]);
1016
1017
        $tData = Helper::getPropertyAsArray($res, 'ZweryfikowanyAdres');
1018
1019
        foreach ($tData as $datum) {
1020
            $answer[] = new ZweryfikowanyAdres($datum);
1021
        }
1022
1023
        return $answer;
1024
    }
1025
1026
    /**
1027
     * Zwraca listę znalezionych jednostek w katalagu TERC
1028
     *
1029
     * @param string $name
1030
     *
1031
     * @return JednostkaPodzialuTerytorialnego[]
1032
     * @todo Metoda zwraca 0 wyników
1033
     */
1034 View Code Duplication
    public function WyszukajJPT(string $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...
1035
    {
1036
        $answer = [];
1037
        $res    = $this->oClient->request('WyszukajJPT', ['nazwa' => $name], false);
1038
        foreach (Helper::getPropertyAsArray($res, 'JednostkaPodzialuTerytorialnego') as $p) {
1039
            $answer[] = new JednostkaPodzialuTerytorialnego($p);
1040
        };
1041
1042
        return $answer;
1043
    }
1044
1045
    /**
1046
     * Zwraca listę znalezionych jednostek w katalagu TERC
1047
     *
1048
     * @param string|null $name     zawiera nazwę wyszukiwanej jednostki
1049
     * @param string|null $category określa kategorię wyszukiwanych jednostek
1050
     * @param string[]    $tSimc    lista identyfikatorów SIMC (cityId)
1051
     * @param string[]    $tTerc    lista identyfikatorów TERC (tercId)
1052
     *
1053
     * @return JednostkaPodzialuTerytorialnego[]
1054
     */
1055 1 View Code Duplication
    public function WyszukajJednostkeWRejestrze(
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...
1056
        string $name = null,
1057
        string $category = null,
1058
        array $tSimc = [],
1059
        array $tTerc = []
1060
    ) {
1061 1
        $answer     = [];
1062 1
        $identyfiks = [];
1063 1
        foreach ($tSimc as $simc) {
1064
            $identyfiks[] = ['simc' => $simc];
1065
        }
1066 1
        foreach ($tTerc as $terc) {
1067 1
            $identyfiks[] = ['terc' => $terc];
1068
        }
1069 1
        $res = $this->oClient->request('WyszukajJednostkeWRejestrze',
1070
            [
1071 1
                'nazwa'      => $name,
1072 1
                'kategoria'  => $category ?? NativeApi::CATEGORY_ALL,
1073 1
                'identyfiks' => $identyfiks,
1074
            ]);
1075 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaPodzialuTerytorialnego') as $p) {
1076 1
            $answer[] = new JednostkaPodzialuTerytorialnego($p);
1077
        };
1078
1079 1
        return $answer;
1080
    }
1081
1082
    /**
1083
     * Zwaraca listę znalezionych miejscowości w katalogu SIMC.
1084
     *
1085
     * @param string|null $cityName
1086
     * @param string|null $cityId
1087
     *
1088
     * @return Miejscowosc[]
1089
     */
1090 View Code Duplication
    public function WyszukajMiejscowosc(string $cityName = null, string $cityId = null)
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...
1091
    {
1092
        $answer = [];
1093
        $res    = $this->oClient->request('WyszukajMiejscowosc',
1094
            ['nazwaMiejscowosci' => $cityName, 'identyfikatorMiejscowosci' => $cityId]);
1095
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
1096
            $answer[] = new Miejscowosc($p);
1097
        };
1098
1099
        return $answer;
1100
    }
1101
1102
    /**
1103
     * Zwaraca listę znalezionych miejscowości we wskazanej
1104
     * jednostce podziału terytorialnego
1105
     *
1106
     * @param string $provinceName
1107
     * @param string $districtName
1108
     * @param string $communeName
1109
     * @param string $cityName
1110
     * @param string $cityId
1111
     *
1112
     * @return Miejscowosc[]
1113
     */
1114 View Code Duplication
    public function WyszukajMiejscowoscWJPT(
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...
1115
        string $provinceName,
1116
        string $districtName,
1117
        string $communeName,
1118
        string $cityName,
1119
        string $cityId = null
1120
    ) {
1121
        $answer = [];
1122
        /**
1123
         * @var \stdClass|null $res
1124
         */
1125
        $res = $this->oClient->request('WyszukajMiejscowoscWJPT',
1126
            [
1127
                'nazwaWoj'                  => $provinceName,
1128
                'nazwaPow'                  => $districtName,
1129
                'nazwaGmi'                  => $communeName,
1130
                'nazwaMiejscowosci'         => $cityName,
1131
                'identyfikatorMiejscowosci' => $cityId,
1132
            ]);
1133
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
1134
            $answer[] = new Miejscowosc($p);
1135
        };
1136
1137
        return $answer;
1138
    }
1139
1140
    /**
1141
     * Zwaraca listę znalezionych miejscowości we wskazanej jednostcepodziału terytorialnego
1142
     *
1143
     * @param string|null $name         Nazwa miejscowości
1144
     * @param string|null $cityId       ID miejscowości
1145
     * @param string[]    $tSimc        Lista cityId w których szukamy
1146
     * @param string[]    $tTerc        Lista tercId w których szukamy
1147
     * @param string      $cityTypeName Predefiniowany typ wyszukiwania ('000','001','002') stałe: SEARCH_CITY_TYPE_*
1148
     *
1149
     * @return WyszukanaMiejscowosc[]
1150
     */
1151 2 View Code Duplication
    public function WyszukajMiejscowoscWRejestrze(
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...
1152
        string $name = null,
1153
        string $cityId = null,
1154
        array $tSimc = [],
1155
        array $tTerc = [],
1156
        string $cityTypeName = NativeApi::SEARCH_CITY_TYPE_ALL
1157
    ) {
1158 2
        $answer     = [];
1159 2
        $identyfiks = [];
1160 2
        foreach ($tSimc as $simc) {
1161
            $identyfiks[] = ['simc' => $simc];
1162
        }
1163 2
        foreach ($tTerc as $terc) {
1164
            $identyfiks[] = ['terc' => $terc];
1165
        }
1166 2
        $res = $this->oClient->request('WyszukajMiejscowoscWRejestrze',
1167
            [
1168 2
                'nazwa'              => $name,
1169 2
                'rodzajMiejscowosci' => $cityTypeName,
1170 2
                'symbol'             => $cityId,
1171 2
                'identyfiks'         => $identyfiks,
1172
            ]);
1173 2
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaMiejscowosc') as $p) {
1174 1
            $answer[] = new WyszukanaMiejscowosc($p);
1175
        };
1176
1177 1
        return $answer;
1178
    }
1179
1180
    /**
1181
     * Wyszukuje wskazaną ulicę w katalogu ULIC. Wyszukiwanie odbywa się za pomoca nazw
1182
     *
1183
     * @param string|null $streetName
1184
     * @param string|null $streetIdentityName
1185
     * @param string|null $cityName
1186
     *
1187
     * @return Ulica[]
1188
     */
1189 View Code Duplication
    public function WyszukajUlice(string $streetName = null, string $streetIdentityName = null, string $cityName = null)
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...
1190
    {
1191
        $answer = [];
1192
        $res    = $this->oClient->request('WyszukajUlice',
1193
            [
1194
                'nazwaulicy'        => $streetName,
1195
                'cecha'             => $streetIdentityName,
1196
                'nazwamiejscowosci' => $cityName,
1197
            ]);
1198
        foreach (Helper::getPropertyAsArray($res, 'Ulica') as $p) {
1199
            $answer[] = new Ulica($p);
1200
        };
1201
1202
        return $answer;
1203
    }
1204
1205
    /**
1206
     * Wyszukuje wskazaną ulicę w katalogu ULIC
1207
     *
1208
     * @param string|null $name         Nazwa ulicy
1209
     * @param string      $identityName Nazwa cechy, wymagane
1210
     * @param string|null $streetId     ID ulicy
1211
     * @param array       $tSimc        Lista cityId w których szukamy
1212
     * @param array       $tTerc        Lista tercId w których szukamy
1213
     *
1214
     * @return WyszukanaUlica[]
1215
     */
1216 View Code Duplication
    public function WyszukajUliceWRejestrze(
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...
1217
        string $name = null,
1218
        string $identityName = 'ul.',
1219
        string $streetId = null,
1220
        array $tSimc = [],
1221
        array $tTerc = []
1222
    ) {
1223
        $answer     = [];
1224
        $identyfiks = [];
1225
        foreach ($tSimc as $simc) {
1226
            $identyfiks[] = ['simc' => $simc];
1227
        }
1228
        foreach ($tTerc as $terc) {
1229
            $identyfiks[] = ['terc' => $terc];
1230
        }
1231
        $res = $this->oClient->request('WyszukajUliceWRejestrze',
1232
            [
1233
                'nazwa'         => $name,
1234
                'cecha'         => $identityName,
1235
                'identyfikator' => $streetId,
1236
                'identyfiks'    => $identyfiks,
1237
            ]);
1238
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaUlica') as $p) {
1239
            $answer[] = new WyszukanaUlica($p);
1240
        };
1241
1242
        return $answer;
1243
    }
1244
}
1245