Passed
Branch master (88d0d9)
by Marcin
04:10 queued 01:30
created

NativeApi   F

Complexity

Total Complexity 90

Size/Duplication

Total Lines 1205
Duplicated Lines 41.24 %

Test Coverage

Coverage 16.25%

Importance

Changes 0
Metric Value
dl 497
loc 1205
ccs 65
cts 400
cp 0.1625
rs 0.6314
c 0
b 0
f 0
wmc 90

56 Methods

Rating   Name   Duplication   Size   Complexity  
A PobierzDateAktualnegoKatUlic() 8 8 2
A WeryfikujAdresDlaMiejscowosci() 6 6 1
A PobierzListeUlicDlaMiejscowosci() 0 21 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() 9 9 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 getInstance() 0 7 2
A WeryfikujAdresWmiejscowosci() 21 21 2
B WyszukajJednostkeWRejestrze() 25 25 4
A __construct() 0 3 1
A create() 0 5 1
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() 0 5 1
B WyszukajMiejscowoscWRejestrze() 27 27 4
A CzyZalogowany() 0 5 1
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 7
    protected function __construct(Client $oClient)
81
    {
82 7
        $this->oClient = $oClient;
83 7
    }
84
85
    /**
86
     * @param \mrcnpdlk\Teryt\Client $oClient
87
     *
88
     * @return \mrcnpdlk\Teryt\NativeApi
89
     */
90 7
    public static function create(Client $oClient)
91
    {
92 7
        static::$instance = new static($oClient);
93
94 7
        return static::$instance;
95
    }
96
97
    /**
98
     * @return \mrcnpdlk\Teryt\NativeApi
99
     * @throws \mrcnpdlk\Teryt\Exception
100
     */
101 2
    public static function getInstance()
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()
116
    {
117 1
        $res = $this->oClient->request('CzyZalogowany');
118
119 1
        return $res;
120
    }
121
122
    /**
123
     * Data początkowa bieżącego stanu katalogu TERC
124
     *
125
     * @return null|string Data w formacie YYY-MM-DD
126
     */
127 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...
128
    {
129
        $res = $this->oClient->request('PobierzDateAktualnegoKatTerc');
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 NTS
140
     *
141
     * @return null|string Data w formacie YYY-MM-DD
142
     */
143 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...
144
    {
145
        $res = $this->oClient->request('PobierzDateAktualnegoKatNTS');
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 SIMC
156
     *
157
     * @return null|string Data w formacie YYY-MM-DD
158
     */
159 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...
160
    {
161
        $res = $this->oClient->request('PobierzDateAktualnegoKatSimc');
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
     * Dane z systemu identyfikatorów TERC z wybranego stanu katalogu w wersji adresowej
188
     *
189
     * @return \SplFileObject
190
     */
191 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...
192
    {
193
        $res     = $this->oClient->request('PobierzKatalogTERCAdr');
194
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
195
        $content = base64_decode($res->plik_zawartosc);
196
197
        return Helper::saveFile($sPath, $content);
198
    }
199
200
    /**
201
     * Dane z systemu identyfikatorów TERC z wybranego stanu katalogu w wersji urzędowej
202
     *
203
     * @return \SplFileObject
204
     */
205 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...
206
    {
207
        $res     = $this->oClient->request('PobierzKatalogTERC');
208
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
209
        $content = base64_decode($res->plik_zawartosc);
210
211
        return Helper::saveFile($sPath, $content);
212
    }
213
214
    /**
215
     * Identyfikatory i nazwy jednostek nomenklatury z wybranego stanu katalogu
216
     *
217
     * @return \SplFileObject
218
     */
219 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...
220
    {
221
        $res     = $this->oClient->request('PobierzKatalogNTS');
222
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
223
        $content = base64_decode($res->plik_zawartosc);
224
225
        return Helper::saveFile($sPath, $content);
226
    }
227
228
    /**
229
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
230
     *
231
     * @return \SplFileObject
232
     */
233 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...
234
    {
235
        $res     = $this->oClient->request('PobierzKatalogSIMCAdr');
236
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
237
        $content = base64_decode($res->plik_zawartosc);
238
239
        return Helper::saveFile($sPath, $content);
240
    }
241
242
    /**
243
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
244
     *
245
     * @return \SplFileObject
246
     */
247 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...
248
    {
249
        $res     = $this->oClient->request('PobierzKatalogSIMC');
250
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
251
        $content = base64_decode($res->plik_zawartosc);
252
253
        return Helper::saveFile($sPath, $content);
254
    }
255
256
    /**
257
     * Dane o miejscowościach z systemu identyfikatorów SIMC z wybranego stanu katalogu w wersji adresowej
258
     *
259
     * @return \SplFileObject
260
     */
261 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...
262
    {
263
        $res     = $this->oClient->request('PobierzKatalogSIMCStat');
264
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
265
        $content = base64_decode($res->plik_zawartosc);
266
267
        return Helper::saveFile($sPath, $content);
268
    }
269
270
    /**
271
     * Katalog ulic dla wskazanego stanu w wersji urzędowej
272
     *
273
     * @return \SplFileObject
274
     */
275 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...
276
    {
277
        $res     = $this->oClient->request('PobierzKatalogULIC');
278
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
279
        $content = base64_decode($res->plik_zawartosc);
280
281
        return Helper::saveFile($sPath, $content);
282
    }
283
284
    /**
285
     * Katalog ulic dla wskazanego stanu w wersji adresowej
286
     *
287
     * @return \SplFileObject
288
     */
289 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...
290
    {
291
        $res     = $this->oClient->request('PobierzKatalogULICAdr');
292
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
293
        $content = base64_decode($res->plik_zawartosc);
294
295
        return Helper::saveFile($sPath, $content);
296
    }
297
298
    /**
299
     * Katalog ulic dla wskazanego stanu w wersji urzędowej zmodyfikowany dla miast posiadający delegatury
300
     *
301
     * @return \SplFileObject
302
     */
303 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...
304
    {
305
        $res     = $this->oClient->request('PobierzKatalogULICBezDzielnic');
306
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
307
        $content = base64_decode($res->plik_zawartosc);
308
309
        return Helper::saveFile($sPath, $content);
310
    }
311
312
    /**
313
     * Katalog rodzajów miejscowości dla wskazanego stanu
314
     *
315
     * @return \SplFileObject
316
     */
317 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...
318
    {
319 1
        $res     = $this->oClient->request('PobierzKatalogWMRODZ');
320 1
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
321 1
        $content = base64_decode($res->plik_zawartosc);
322
323 1
        return Helper::saveFile($sPath, $content);
324
    }
325
326
    /**
327
     * Zmiany w katalogu TERC w wersji urzędowej rejestru
328
     *
329
     * @param \DateTime      $fromDate
330
     * @param \DateTime|null $toDate
331
     *
332
     * @return \SplFileObject
333
     */
334 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...
335
    {
336
        $toDate  = $toDate ?? new \DateTime();
337
        $res     = $this->oClient->request(
338
            'PobierzZmianyTercUrzedowy',
339
            [
340
                'stanod' => $fromDate->format('Y-m-d'),
341
                'stando' => $toDate->format('Y-m-d'),
0 ignored issues
show
Bug introduced by
The method format() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

341
                'stando' => $toDate->/** @scrutinizer ignore-call */ format('Y-m-d'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
342
            ],
343
            false);
344
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
345
        $content = base64_decode($res->plik_zawartosc);
346
347
        return Helper::saveFile($sPath, $content);
348
    }
349
350
    /**
351
     * Zmiany w katalogu TERC w wersji adresowej rejestru
352
     *
353
     * @param \DateTime      $fromDate
354
     * @param \DateTime|null $toDate
355
     *
356
     * @return \SplFileObject
357
     */
358 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...
359
    {
360 1
        $toDate  = $toDate ?? new \DateTime();
361 1
        $res     = $this->oClient->request(
362 1
            'PobierzZmianyTercAdresowy',
363
            [
364 1
                'stanod' => $fromDate->format('Y-m-d'),
365 1
                'stando' => $toDate->format('Y-m-d'),
366
            ],
367 1
            false);
368 1
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
369 1
        $content = base64_decode($res->plik_zawartosc);
370
371 1
        return Helper::saveFile($sPath, $content);
372
    }
373
374
    /**
375
     * Zmiany w katalogu TERC w wersji adresowej rejestru
376
     *
377
     * @param \DateTime      $fromDate
378
     * @param \DateTime|null $toDate
379
     *
380
     * @return \SplFileObject
381
     */
382 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...
383
    {
384
        $toDate  = $toDate ?? new \DateTime();
385
        $res     = $this->oClient->request(
386
            'PobierzZmianyNTS',
387
            [
388
                'stanod' => $fromDate->format('Y-m-d'),
389
                'stando' => $toDate->format('Y-m-d'),
390
            ],
391
            false);
392
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
393
        $content = base64_decode($res->plik_zawartosc);
394
395
        return Helper::saveFile($sPath, $content);
396
    }
397
398
    /**
399
     * Zmiany w katalogu SIMC w wersji urzędowej rejestru
400
     *
401
     * @param \DateTime      $fromDate
402
     * @param \DateTime|null $toDate
403
     *
404
     * @return \SplFileObject
405
     */
406 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...
407
    {
408
        $toDate  = $toDate ?? new \DateTime();
409
        $res     = $this->oClient->request(
410
            'PobierzZmianySimcUrzedowy',
411
            [
412
                'stanod' => $fromDate->format('Y-m-d'),
413
                'stando' => $toDate->format('Y-m-d'),
414
            ],
415
            false);
416
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
417
        $content = base64_decode($res->plik_zawartosc);
418
419
        return Helper::saveFile($sPath, $content);
420
    }
421
422
    /**
423
     * Zmiany w katalogu SIMC w wersji adresowej rejestru
424
     *
425
     * @param \DateTime      $fromDate
426
     * @param \DateTime|null $toDate
427
     *
428
     * @return \SplFileObject
429
     */
430 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...
431
    {
432
        $toDate  = $toDate ?? new \DateTime();
433
        $res     = $this->oClient->request(
434
            'PobierzZmianySimcAdresowy',
435
            [
436
                'stanod' => $fromDate->format('Y-m-d'),
437
                'stando' => $toDate->format('Y-m-d'),
438
            ],
439
            false);
440
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
441
        $content = base64_decode($res->plik_zawartosc);
442
443
        return Helper::saveFile($sPath, $content);
444
    }
445
446
    /**
447
     * Zmiany w katalogu SIMC w wersji statystycznej rejestru
448
     *
449
     * @param \DateTime      $fromDate
450
     * @param \DateTime|null $toDate
451
     *
452
     * @return \SplFileObject
453
     */
454 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...
455
    {
456
        $toDate  = $toDate ?? new \DateTime();
457
        $res     = $this->oClient->request(
458
            'PobierzZmianySimcStatystyczny',
459
            [
460
                'stanod' => $fromDate->format('Y-m-d'),
461
                'stando' => $toDate->format('Y-m-d'),
462
            ],
463
            false);
464
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
465
        $content = base64_decode($res->plik_zawartosc);
466
467
        return Helper::saveFile($sPath, $content);
468
    }
469
470
    /**
471
     * Zmiany w katalogu ULIC w wersji urzędowej rejestru
472
     *
473
     * @param \DateTime      $fromDate
474
     * @param \DateTime|null $toDate
475
     *
476
     * @return \SplFileObject
477
     */
478 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...
479
    {
480
        $toDate  = $toDate ?? new \DateTime();
481
        $res     = $this->oClient->request(
482
            'PobierzZmianyUlicUrzedowy',
483
            [
484
                'stanod' => $fromDate->format('Y-m-d'),
485
                'stando' => $toDate->format('Y-m-d'),
486
            ],
487
            false);
488
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
489
        $content = base64_decode($res->plik_zawartosc);
490
491
        return Helper::saveFile($sPath, $content);
492
    }
493
494
    /**
495
     * Zmiany w katalogu ULIC w wersji adresowej rejestru
496
     *
497
     * @param \DateTime      $fromDate
498
     * @param \DateTime|null $toDate
499
     *
500
     * @return \SplFileObject
501
     */
502 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...
503
    {
504
        $toDate  = $toDate ?? new \DateTime();
505
        $res     = $this->oClient->request(
506
            'PobierzZmianyUlicAdresowy',
507
            [
508
                'stanod' => $fromDate->format('Y-m-d'),
509
                'stando' => $toDate->format('Y-m-d'),
510
            ],
511
            false);
512
        $sPath   = sprintf('%s/%s.zip', sys_get_temp_dir(), $res->nazwa_pliku);
513
        $content = base64_decode($res->plik_zawartosc);
514
515
        return Helper::saveFile($sPath, $content);
516
    }
517
518
    /**
519
     * Zwraca listę rodzajów jednostek
520
     *
521
     * @return string[]
522
     */
523
    public function PobierzSlownikRodzajowJednostek()
524
    {
525
        $res = $this->oClient->request('PobierzSlownikRodzajowJednostek');
526
527
        return Helper::getPropertyAsArray($res, 'string');
528
    }
529
530
    /**
531
     * Zwraca listę rodzajów miejscowości
532
     *
533
     * @return RodzajMiejscowosci[]
534
     */
535
    public function PobierzSlownikRodzajowSIMC()
536
    {
537
        $answer = [];
538
        $res    = $this->oClient->request('PobierzSlownikRodzajowSIMC');
539
        foreach (Helper::getPropertyAsArray($res, 'RodzajMiejscowosci') as $p) {
540
            $answer[] = new RodzajMiejscowosci($p);
541
        };
542
543
        return $answer;
544
    }
545
546
    /**
547
     * Zwraca listę cech obiektów z katalogu ulic
548
     *
549
     * @return string[]
550
     */
551
    public function PobierzSlownikCechULIC()
552
    {
553
        $res = $this->oClient->request('PobierzSlownikCechULIC');
554
555
        return Helper::getPropertyAsArray($res, 'string');
556
    }
557
558
    /**
559
     * Lista regionów
560
     *
561
     * @return JednostkaNomenklaturyNTS[]
562
     */
563
    public function PobierzListeRegionow()
564
    {
565
        $answer = [];
566
        $res    = $this->oClient->request('PobierzListeRegionow');
567
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
568
            $answer[] = new JednostkaNomenklaturyNTS($p);
569
        };
570
571
        return $answer;
572
    }
573
574
    /**
575
     * Lista województw regionie
576
     *
577
     * @param string $regionId Jednoznakowy symbol regionu
578
     *
579
     * @return JednostkaNomenklaturyNTS[]
580
     */
581
    public function PobierzListeWojewodztwWRegionie(string $regionId)
582
    {
583
        $answer = [];
584
        $res    = $this->oClient->request('PobierzListeWojewodztwWRegionie', ['Reg' => $regionId]);
585
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
586
            $answer[] = new JednostkaNomenklaturyNTS($p);
587
        };
588
589
        return $answer;
590
    }
591
592
    /**
593
     * Lista podregionów w województwie
594
     *
595
     * @param string $provinceId Dwuznakowy symbol województwa
596
     *
597
     * @return JednostkaNomenklaturyNTS[]
598
     */
599
    public function PobierzListePodregionow(string $provinceId)
600
    {
601
        $answer = [];
602
        $res    = $this->oClient->request('PobierzListePodregionow', ['Woj' => $provinceId]);
603
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
604
            $answer[] = new JednostkaNomenklaturyNTS($p);
605
        };
606
607
        return $answer;
608
    }
609
610
    /**
611
     * Lista powiatów w podregionie
612
     *
613
     * @param string $subregionId Dwuznakowy symbol podregionu
614
     *
615
     * @return JednostkaNomenklaturyNTS[]
616
     */
617
    public function PobierzListePowiatowWPodregionie(string $subregionId)
618
    {
619
        $answer = [];
620
        $res    = $this->oClient->request('PobierzListePowiatowWPodregionie', ['Podreg' => $subregionId]);
621
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
622
            $answer[] = new JednostkaNomenklaturyNTS($p);
623
        };
624
625
        return $answer;
626
    }
627
628
    /**
629
     * Lista gmin w powiecie
630
     *
631
     * @param string $districtId  dwuznakowy symbol powiatu
632
     * @param string $subregionId dwuznakowy symbol podregionu
633
     *
634
     * @return JednostkaNomenklaturyNTS[]
635
     */
636
    public function PobierzListeGminPowiecie(string $districtId, string $subregionId)
637
    {
638
        $answer = [];
639
        $res    = $this->oClient->request('PobierzListeGminPowiecie', ['Pow' => $districtId, 'Podreg' => $subregionId]);
640
        foreach (Helper::getPropertyAsArray($res, 'JednostkaNomenklaturyNTS') as $p) {
641
            $answer[] = new JednostkaNomenklaturyNTS($p);
642
        };
643
644
        return $answer;
645
    }
646
647
    /**
648
     * Zwraca listę znalezionych jednostek w katalagu TERC
649
     *
650
     * @param string $name
651
     *
652
     * @return mixed
653
     * @todo Metoda zwraca 0 wyników
654
     */
655
    public function WyszukajJPT(string $name)
656
    {
657
        $res = $this->oClient->request('WyszukajJPT', ['Nazwa' => $name]);
658
659
        return $res;
660
    }
661
662
    /**
663
     * Zwaraca listę znalezionych miejscowości w katalogu SIMC.
664
     *
665
     * @param string|null $cityName
666
     * @param string|null $cityId
667
     *
668
     * @return Miejscowosc[]
669
     */
670 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...
671
    {
672
        $answer = [];
673
        $res    = $this->oClient->request('WyszukajMiejscowosc', ['nazwaMiejscowosci' => $cityName, 'identyfikatorMiejscowosci' => $cityId]);
674
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
675
            $answer[] = new Miejscowosc($p);
676
        };
677
678
        return $answer;
679
    }
680
681
    /**
682
     * Zwaraca listę znalezionych miejscowości we wskazanej
683
     * jednostce podziału terytorialnego
684
     *
685
     * @param string $provinceName
686
     * @param string $districtName
687
     * @param string $communeName
688
     * @param string $cityName
689
     * @param string $cityId
690
     *
691
     * @return Miejscowosc[]
692
     */
693 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...
694
        string $provinceName,
695
        string $districtName,
696
        string $communeName,
697
        string $cityName,
698
        string $cityId = null
699
    ) {
700
        $answer = [];
701
        /**
702
         * @var \stdClass|null $res
703
         */
704
        $res = $this->oClient->request('WyszukajMiejscowoscWJPT',
705
            [
706
                'nazwaWoj'                  => $provinceName,
707
                'nazwaPow'                  => $districtName,
708
                'nazwaGmi'                  => $communeName,
709
                'nazwaMiejscowosci'         => $cityName,
710
                'identyfikatorMiejscowosci' => $cityId,
711
            ]);
712
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
713
            $answer[] = new Miejscowosc($p);
714
        };
715
716
        return $answer;
717
    }
718
719
    /**
720
     * Wyszukuje wskazaną ulicę w katalogu ULIC. Wyszukiwanie
721
     * odbywa się za pomoca nazw
722
     *
723
     * @param string|null $streetName
724
     * @param string|null $streetIdentityName
725
     * @param string|null $cityName
726
     *
727
     * @return Ulica[]
728
     */
729 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...
730
    {
731
        $answer = [];
732
        $res    = $this->oClient->request('WyszukajUlice',
733
            [
734
                'nazwaulicy'        => $streetName,
735
                'cecha'             => $streetIdentityName,
736
                'nazwamiejscowosci' => $cityName,
737
            ]);
738
        foreach (Helper::getPropertyAsArray($res, 'Ulica') as $p) {
739
            $answer[] = new Ulica($p);
740
        };
741
742
        return $answer;
743
    }
744
745
    /**
746
     * Zwraca listę znalezionych jednostek w katalagu TERC
747
     *
748
     * @param string|null $name     zawiera nazwę wyszukiwanej jednostki
749
     * @param string|null $category określa kategorię wyszukiwanych jednostek
750
     * @param string[]    $tSimc    lista identyfikatorów SIMC (cityId)
751
     * @param string[]    $tTerc    lista identyfikatorów TERC (tercId)
752
     *
753
     * @return JednostkaPodzialuTerytorialnego[]
754
     */
755 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...
756
        string $name = null,
757
        string $category = null,
758
        array $tSimc = [],
759
        array $tTerc = []
760
    ) {
761 1
        $answer     = [];
762 1
        $identyfiks = [];
763 1
        foreach ($tSimc as $simc) {
764
            $identyfiks[] = ['simc' => $simc];
765
        }
766 1
        foreach ($tTerc as $terc) {
767 1
            $identyfiks[] = ['terc' => $terc];
768
        }
769 1
        $res = $this->oClient->request('WyszukajJednostkeWRejestrze',
770
            [
771 1
                'nazwa'      => $name,
772 1
                'kategoria'  => $category ?? NativeApi::CATEGORY_ALL,
773 1
                'identyfiks' => $identyfiks,
774
            ]);
775 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaPodzialuTerytorialnego') as $p) {
776 1
            $answer[] = new JednostkaPodzialuTerytorialnego($p);
777
        };
778
779 1
        return $answer;
780
    }
781
782
    /**
783
     * Zwaraca listę znalezionych miejscowości we wskazanej
784
     * jednostcepodziału terytorialnego
785
     *
786
     * @param string|null $name         Nazwa miejscowości
787
     * @param string|null $cityId       ID miejscowości
788
     * @param array       $tSimc        Lista cityId w których szukamy
789
     * @param array       $tTerc        Lista tercId w których szukamy
790
     * @param string      $cityTypeName Predefinowany typ wyszukiwania ('000','001','002')
791
     *
792
     * @return WyszukanaMiejscowosc[]
793
     */
794 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...
795
        string $name = null,
796
        string $cityId = null,
797
        array $tSimc = [],
798
        array $tTerc = [],
799
        string $cityTypeName = NativeApi::SEARCH_CITY_TYPE_ALL
800
    ) {
801 2
        $answer     = [];
802 2
        $identyfiks = [];
803 2
        foreach ($tSimc as $simc) {
804
            $identyfiks[] = ['simc' => $simc];
805
        }
806 2
        foreach ($tTerc as $terc) {
807
            $identyfiks[] = ['terc' => $terc];
808
        }
809 2
        $res = $this->oClient->request('WyszukajMiejscowoscWRejestrze',
810
            [
811 2
                'nazwa'              => $name,
812 2
                'rodzajMiejscowosci' => $cityTypeName,
813 2
                'symbol'             => $cityId,
814 2
                'identyfiks'         => $identyfiks,
815
            ]);
816 2
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaMiejscowosc') as $p) {
817 1
            $answer[] = new WyszukanaMiejscowosc($p);
818
        };
819
820 1
        return $answer;
821
    }
822
823
    /**
824
     * Wyszukuje wskazaną ulicę w katalogu ULIC
825
     *
826
     * @param string|null $name         Nazwa ulicy
827
     * @param string      $identityName Nazwa cechy, wymagane
828
     * @param string|null $streetId     ID ulicy
829
     * @param array       $tSimc        Lista cityId w których szukamy
830
     * @param array       $tTerc        Lista tercId w których szukamy
831
     *
832
     * @return WyszukanaUlica[]
833
     */
834 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...
835
        string $name = null,
836
        string $identityName = 'ul.',
837
        string $streetId = null,
838
        array $tSimc = [],
839
        array $tTerc = []
840
    ) {
841
        $answer     = [];
842
        $identyfiks = [];
843
        foreach ($tSimc as $simc) {
844
            $identyfiks[] = ['simc' => $simc];
845
        }
846
        foreach ($tTerc as $terc) {
847
            $identyfiks[] = ['terc' => $terc];
848
        }
849
        $res = $this->oClient->request('WyszukajUliceWRejestrze',
850
            [
851
                'nazwa'         => $name,
852
                'cecha'         => $identityName,
853
                'identyfikator' => $streetId,
854
                'identyfiks'    => $identyfiks,
855
            ]);
856
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaUlica') as $p) {
857
            $answer[] = new WyszukanaUlica($p);
858
        };
859
860
        return $answer;
861
    }
862
863
    /**
864
     * Lista miejscowości znajdujących się we wskazanej gminie.
865
     * Wyszukiwanie odbywa się z uwzględnieniem nazw
866
     *
867
     * @param string $provinceName
868
     * @param string $districtName
869
     * @param string $communeName
870
     *
871
     * @return Miejscowosc[]
872
     * @todo Metoda nie działa
873
     */
874
    public function PobierzListeMiejscowosciWGminie(string $provinceName, string $districtName, string $communeName)
875
    {
876
        $answer = [];
877
        $res    = $this->oClient->request('PobierzListeMiejscowosciWGminie',
878
            [
879
                'wojewodztwo' => $provinceName,
880
                'Powiat'      => $districtName,
881
                'Gmina'       => $communeName,
882
            ]);
883
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
884
            $answer[] = new Miejscowosc($p);
885
        };
886
887
        return $answer;
888
    }
889
890
    /**
891
     * Lista miejscowości znajdujących się we wskazanej gminie.
892
     * Wyszukiwanie odbywa się z uwzględnieniem symboli
893
     *
894
     * @param int $tercId
895
     *
896
     * @return Miejscowosc[]
897
     * @todo Zwraca niezgodne typy - połatane
898
     */
899
    public function PobierzListeMiejscowosciWRodzajuGminy(int $tercId)
900
    {
901
        $answer = [];
902
        $oTerc  = new Terc($tercId);
903
        $res    = $this->oClient->request('PobierzListeMiejscowosciWRodzajuGminy',
904
            [
905
                'symbolWoj'  => $oTerc->getProvinceId(),
906
                'symbolPow'  => $oTerc->getDistrictId(),
907
                'symbolGmi'  => $oTerc->getCommuneId(),
908
                'symbolRodz' => $oTerc->getCommuneTypeId(),
909
            ]);
910
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
911
            $answer[] = new Miejscowosc($p);
912
        };
913
914
        return $answer;
915
    }
916
917
    /**
918
     * Lista województw
919
     *
920
     * @return JednostkaTerytorialna[]
921
     */
922 3
    public function PobierzListeWojewodztw()
923
    {
924 3
        $answer = [];
925 3
        $res    = $this->oClient->request('PobierzListeWojewodztw');
926 2
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
927 2
            $answer[] = new JednostkaTerytorialna($p);
928
        };
929
930 2
        return $answer;
931
    }
932
933
    /**
934
     * Pobieranie listy powiatów dla danego województwa
935
     *
936
     * @param string $provinceId
937
     *
938
     * @return JednostkaTerytorialna[]
939
     */
940 1
    public function PobierzListePowiatow(string $provinceId)
941
    {
942 1
        $answer = [];
943 1
        $res    = $this->oClient->request('PobierzListePowiatow', ['Woj' => $provinceId]);
944 1
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
945 1
            $answer[] = new JednostkaTerytorialna($p);
946
        };
947
948 1
        return $answer;
949
    }
950
951
    /**
952
     * Lista gmin we wskazanym powiecie
953
     *
954
     * @param string $provinceId
955
     * @param string $districtId
956
     *
957
     * @return JednostkaTerytorialna[]
958
     */
959
    public function PobierzListeGmin(string $provinceId, string $districtId)
960
    {
961
        $answer = [];
962
        $res    = $this->oClient->request('PobierzListeGmin', ['Woj' => $provinceId, 'Pow' => $districtId]);
963
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
964
            $answer[] = new JednostkaTerytorialna($p);
965
        };
966
967
        return $answer;
968
    }
969
970
    /**
971
     * Lista powiatów i gmin we wskazanym województwie
972
     *
973
     * @param string $provinceId
974
     *
975
     * @return JednostkaTerytorialna[]
976
     */
977
    public function PobierzGminyiPowDlaWoj(string $provinceId)
978
    {
979
        $answer = [];
980
        $res    = $this->oClient->request('PobierzGminyiPowDlaWoj', ['Woj' => $provinceId]);
981
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
982
            $answer[] = new JednostkaTerytorialna($p);
983
        };
984
985
        return $answer;
986
    }
987
988
    /**
989
     * Lista ulic we wskazanej miejscowości
990
     *
991
     * @param int    $tercId
992
     * @param string $cityId
993
     * @param bool   $asAddress
994
     *
995
     * @return UlicaDrzewo[]
996
     * @todo Metoda nie działa poprawnie
997
     */
998
    public function PobierzListeUlicDlaMiejscowosci(int $tercId, string $cityId, bool $asAddress = false)
999
    {
1000
        $answer = [];
1001
        $oTerc  = new Terc($tercId);
1002
        $res    = $this->oClient->request('PobierzListeUlicDlaMiejscowosci',
1003
            [
1004
                'Woj'               => $oTerc->getProvinceId(),
1005
                'Pow'               => $oTerc->getDistrictId(),
1006
                'Gmi'               => $oTerc->getCommuneId(),
1007
                'Rodz'              => $oTerc->getCommuneTypeId(),
1008
                'msc'               => $cityId,
1009
                'czyWersjaUrzedowa' => !$asAddress,
1010
                'czyWersjaAdresowa' => $asAddress,
1011
            ]
1012
        );
1013
1014
        foreach (Helper::getPropertyAsArray($res, 'UlicaDrzewo') as $p) {
1015
            $answer[] = new UlicaDrzewo($p);
1016
        };
1017
1018
        return $answer;
1019
    }
1020
1021
    /**
1022
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
1023
     * miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
1024
     *
1025
     * @param string $cityId
1026
     *
1027
     * @return ZweryfikowanyAdresBezUlic
1028
     */
1029 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...
1030
    {
1031
        $res   = $this->oClient->request('WeryfikujAdresDlaMiejscowosci', ['symbolMsc' => $cityId]);
1032
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
1033
1034
        return new ZweryfikowanyAdresBezUlic($oData);
1035
    }
1036
1037
    /**
1038
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT,w wersji
1039
     * adresowej rejestru do poziomu miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
1040
     *
1041
     * @param string $cityId
1042
     *
1043
     * @return ZweryfikowanyAdresBezUlic
1044
     */
1045 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...
1046
    {
1047
        $res   = $this->oClient->request('WeryfikujAdresDlaMiejscowosciAdresowy', ['symbolMsc' => $cityId]);
1048
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
1049
1050
        return new ZweryfikowanyAdresBezUlic($oData);
1051
    }
1052
1053
    /**
1054
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
1055
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
1056
     *
1057
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
1058
     * w wtórym zostanie zwrócona tablica wyników
1059
     *
1060
     * @param string      $provinceName Nazwa województwa
1061
     * @param string      $districtName Nazwa powiatu
1062
     * @param string      $communeName  Nazwa gminy
1063
     * @param string      $cityName     Nazwa miejscowości
1064
     * @param string|null $cityTypeName Nazwa typu miejscowości
1065
     *
1066
     * @return ZweryfikowanyAdresBezUlic[]
1067
     */
1068 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...
1069
        string $provinceName,
1070
        string $districtName,
1071
        string $communeName,
1072
        string $cityName,
1073
        string $cityTypeName = null
1074
    ) {
1075
        $answer = [];
1076
        $res    = $this->oClient->request('WeryfikujAdresWmiejscowosci',
1077
            [
1078
                'Wojewodztwo' => $provinceName,
1079
                'Powiat'      => $districtName,
1080
                'Gmina'       => $communeName,
1081
                'Miejscowosc' => $cityName,
1082
                'Rodzaj'      => $cityTypeName,
1083
            ]);
1084
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
1085
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
1086
        };
1087
1088
        return $answer;
1089
    }
1090
1091
    /**
1092
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT w wersji adresowej do poziomu
1093
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
1094
     *
1095
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
1096
     * w wtórym zostanie zwrócona tablica wyników
1097
     *
1098
     * @param string      $provinceName Nazwa województwa
1099
     * @param string      $districtName Nazwa powiatu
1100
     * @param string      $communeName  Nazwa gminy
1101
     * @param string      $cityName     Nazwa miejscowości
1102
     * @param string|null $cityTypeName Nazwa typu miejscowości
1103
     *
1104
     * @return ZweryfikowanyAdresBezUlic[]
1105
     */
1106 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...
1107
        string $provinceName,
1108
        string $districtName,
1109
        string $communeName,
1110
        string $cityName,
1111
        string $cityTypeName = null
1112
    ) {
1113
        $answer = [];
1114
        $res    = $this->oClient->request('WeryfikujAdresWmiejscowosciAdresowy',
1115
            [
1116
                'Wojewodztwo' => $provinceName,
1117
                'Powiat'      => $districtName,
1118
                'Gmina'       => $communeName,
1119
                'Miejscowosc' => $cityName,
1120
                'Rodzaj'      => $cityTypeName,
1121
            ]);
1122
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
1123
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
1124
        };
1125
1126
        return $answer;
1127
    }
1128
1129
    /**
1130
     * Weryfikuje istnienie wskazanego obiektu w bazie
1131
     * TERYT do poziomu ulic.Weryfikacja odbywa się za pomoca nazw
1132
     *
1133
     * @param string $cityId
1134
     * @param string $streetId
1135
     *
1136
     * @return ZweryfikowanyAdres
1137
     */
1138 View Code Duplication
    public function WeryfikujAdresDlaUlic(string $cityId, string $streetId)
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...
1139
    {
1140
        $res   = $this->oClient->request('WeryfikujAdresDlaUlic', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
1141
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
1142
1143
        return new ZweryfikowanyAdres($oData);
1144
    }
1145
1146
    /**
1147
     * Weryfikuje istnienie wskazanego obiektu w bazie
1148
     * TERYT do poziomu ulic w wersji adresowej. Weryfikacja odbywa się za pomoca nazw
1149
     *
1150
     * @param string $cityId
1151
     * @param string $streetId
1152
     *
1153
     * @return ZweryfikowanyAdres
1154
     */
1155 View Code Duplication
    public function WeryfikujAdresDlaUlicAdresowy(string $cityId, string $streetId)
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...
1156
    {
1157
        $res   = $this->oClient->request('WeryfikujAdresDlaUlicAdresowy', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
1158
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
1159
1160
        return new ZweryfikowanyAdres($oData);
1161
    }
1162
1163
    /**
1164
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu ulic.
1165
     * Weryfikacja odbywa się za pomoca nazw
1166
     *
1167
     * @param string      $provinceName
1168
     * @param string      $districtName
1169
     * @param string      $communeName
1170
     * @param string      $cityName
1171
     * @param string|null $cityTypeName
1172
     * @param string      $streetName
1173
     *
1174
     * @return ZweryfikowanyAdres[]
1175
     */
1176 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...
1177
        string $provinceName,
1178
        string $districtName,
1179
        string $communeName,
1180
        string $cityName,
1181
        string $cityTypeName = null,
1182
        string $streetName
1183
    ) {
1184
        $answer = [];
1185
        $res    = $this->oClient->request('WeryfikujNazwaAdresUlic',
1186
            [
1187
                'nazwaWoj'         => $provinceName,
1188
                'nazwaPow'         => $districtName,
1189
                'nazwaGmi'         => $communeName,
1190
                'nazwaMiejscowosc' => $cityName,
1191
                'rodzajMiejsc'     => $cityTypeName,
1192
                'nazwaUlicy'       => $streetName,
1193
            ]);
1194
1195
        $tData = Helper::getPropertyAsArray($res, 'ZweryfikowanyAdres');
1196
1197
        foreach ($tData as $datum) {
1198
            $answer[] = new ZweryfikowanyAdres($datum);
1199
        }
1200
1201
        return $answer;
1202
    }
1203
1204
    /**
1205
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu ulic w wersji adresowej rejestru.
1206
     * Weryfikacja odbywa się za pomoca nazw
1207
     *
1208
     * @param string      $provinceName
1209
     * @param string      $districtName
1210
     * @param string      $communeName
1211
     * @param string      $cityName
1212
     * @param string|null $cityTypeName
1213
     * @param string      $streetName
1214
     *
1215
     * @return ZweryfikowanyAdres[]
1216
     */
1217 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...
1218
        string $provinceName,
1219
        string $districtName,
1220
        string $communeName,
1221
        string $cityName,
1222
        string $cityTypeName = null,
1223
        string $streetName
1224
    ) {
1225
        $answer = [];
1226
        $res    = $this->oClient->request('WeryfikujNazwaAdresUlicAdresowy',
1227
            [
1228
                'nazwaWoj'         => $provinceName,
1229
                'nazwaPow'         => $districtName,
1230
                'nazwaGmi'         => $communeName,
1231
                'nazwaMiejscowosc' => $cityName,
1232
                'rodzajMiejsc'     => $cityTypeName,
1233
                'nazwaUlicy'       => $streetName,
1234
            ]);
1235
1236
        $tData = Helper::getPropertyAsArray($res, 'ZweryfikowanyAdres');
1237
1238
        foreach ($tData as $datum) {
1239
            $answer[] = new ZweryfikowanyAdres($datum);
1240
        }
1241
1242
        return $answer;
1243
    }
1244
}
1245