Completed
Push — master ( 84750e...bb7498 )
by Marcin
02:41
created

Search::WyszukajUliceWRejestrze()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 28
Code Lines 14

Duplication

Lines 28
Ratio 100 %

Importance

Changes 0
Metric Value
dl 28
loc 28
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 14
nc 8
nop 5
1
<?php
2
/**
3
 * TERYT-API
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * For the full copyright and license information, please view source file
8
 * that is bundled with this package in the file LICENSE
9
 *
10
 * Author Marcin Pudełek <[email protected]>
11
 *
12
 */
13
14
/**
15
 * Created by Marcin.
16
 * Date: 10.09.2017
17
 * Time: 12:55
18
 */
19
20
namespace mrcnpdlk\Teryt\Api;
21
22
23
use mrcnpdlk\Teryt\Client;
24
use mrcnpdlk\Teryt\Helper;
25
use mrcnpdlk\Teryt\ResponseModel\Territory\WyszukanaMiejscowosc;
26
27
class Search
28
{
29
    /**
30
     * Zwraca listę znalezionych jednostek w katalagu TERC
31
     *
32
     * @param string $name
33
     *
34
     * @return mixed
35
     * @todo Metoda zwraca 0 wyników
36
     */
37
    public static function WyszukajJPT(string $name)
38
    {
39
        $res = Client::getInstance()->request('WyszukajJPT', ['Nazwa' => $name]);
40
41
        return $res;
42
    }
43
44
    /**
45
     * Zwaraca listę znalezionych miejscowości w katalogu SIMC.
46
     *
47
     * @param string|null $cityName
48
     * @param string|null $cityId
49
     *
50
     * @return Miejscowosc[]
51
     */
52 View Code Duplication
    public static 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...
53
    {
54
        $answer = [];
55
        $res    = Client::getInstance()->request('WyszukajMiejscowosc', ['nazwaMiejscowosci' => $cityName, 'identyfikatorMiejscowosci' => $cityId]);
56
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
57
            $answer[] = new Miejscowosc($p);
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\Miejscowosc was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
58
        };
59
60
        return $answer;
61
    }
62
63
    /**
64
     * Zwaraca listę znalezionych miejscowości we wskazanej
65
     * jednostce podziału terytorialnego
66
     *
67
     * @param string $provinceName
68
     * @param string $districtName
69
     * @param string $communeName
70
     * @param string $cityName
71
     * @param string $cityId
72
     *
73
     * @return Miejscowosc[]
74
     */
75 View Code Duplication
    public static 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...
76
        string $provinceName,
77
        string $districtName,
78
        string $communeName,
79
        string $cityName,
80
        string $cityId = null
81
    ) {
82
        $answer = [];
83
        /**
84
         * @var \stdClass|null $res
85
         */
86
        $res = Client::getInstance()->request('WyszukajMiejscowoscWJPT',
87
            [
88
                'nazwaWoj'                  => $provinceName,
89
                'nazwaPow'                  => $districtName,
90
                'nazwaGmi'                  => $communeName,
91
                'nazwaMiejscowosci'         => $cityName,
92
                'identyfikatorMiejscowosci' => $cityId,
93
            ])
94
        ;
95
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
96
            $answer[] = new Miejscowosc($p);
97
        };
98
99
        return $answer;
100
    }
101
102
    /**
103
     * Wyszukuje wskazaną ulicę w katalogu ULIC. Wyszukiwanie
104
     * odbywa się za pomoca nazw
105
     *
106
     * @param string|null $streetName
107
     * @param string|null $streetIdentityName
108
     * @param string|null $cityName
109
     *
110
     * @return Ulica[]
111
     */
112 View Code Duplication
    public static 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...
113
    {
114
        $answer = [];
115
        $res    = Client::getInstance()->request('WyszukajUlice',
116
            [
117
                'nazwaulicy'        => $streetName,
118
                'cecha'             => $streetIdentityName,
119
                'nazwamiejscowosci' => $cityName,
120
            ])
121
        ;
122
        foreach (Helper::getPropertyAsArray($res, 'Ulica') as $p) {
123
            $answer[] = new Ulica($p);
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\Ulica was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
124
        };
125
126
        return $answer;
127
    }
128
129
    /**
130
     * Zwraca listę znalezionych jednostek w katalagu TERC
131
     *
132
     * @param string|null $name     zawiera nazwę wyszukiwanej jednostki
133
     * @param string|null $category określa kategorię wyszukiwanych jednostek
134
     * @param string[]    $tSimc    lista identyfikatorów SIMC (cityId)
135
     * @param string[]    $tTerc    lista identyfikatorów TERC (tercId)
136
     *
137
     * @return JednostkaPodzialuTerytorialnego[]
138
     */
139 View Code Duplication
    public static 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...
140
        string $name = null,
141
        string $category = null,
142
        array $tSimc = [],
143
        array $tTerc = []
144
    ) {
145
        $answer     = [];
146
        $identyfiks = [];
147
        foreach ($tSimc as $simc) {
148
            $identyfiks[] = ['simc' => $simc];
149
        }
150
        foreach ($tTerc as $terc) {
151
            $identyfiks[] = ['terc' => $terc];
152
        }
153
        $res = Client::getInstance()->request('WyszukajJednostkeWRejestrze',
154
            [
155
                'nazwa'      => $name,
156
                'kategoria'  => $category ?? Api::CATEGORY_ALL,
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\Api was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
157
                'identyfiks' => $identyfiks,
158
            ])
159
        ;
160
        foreach (Helper::getPropertyAsArray($res, 'JednostkaPodzialuTerytorialnego') as $p) {
161
            $answer[] = new JednostkaPodzialuTerytorialnego($p);
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\JednostkaPodzialuTerytorialnego was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
162
        };
163
164
        return $answer;
165
    }
166
167
    /**
168
     * Zwaraca listę znalezionych miejscowości we wskazanej
169
     * jednostcepodziału terytorialnego
170
     *
171
     * @param string|null $name         Nazwa miejscowości
172
     * @param string|null $cityId       ID miejscowości
173
     * @param array       $tSimc        Lista cityId w których szukamy
174
     * @param array       $tTerc        Lista tercId w których szukamy
175
     * @param string      $cityTypeName Predefinowany typ wyszukiwania ('000','001','002')
176
     *
177
     * @return WyszukanaMiejscowosc[]
178
     */
179 View Code Duplication
    public static 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...
180
        string $name = null,
181
        string $cityId = null,
182
        array $tSimc = [],
183
        array $tTerc = [],
184
        string $cityTypeName = Api::SEARCH_CITY_TYPE_ALL
185
    ) {
186
        $answer     = [];
187
        $identyfiks = [];
188
        foreach ($tSimc as $simc) {
189
            $identyfiks[] = ['simc' => $simc];
190
        }
191
        foreach ($tTerc as $terc) {
192
            $identyfiks[] = ['terc' => $terc];
193
        }
194
        $res = Client::getInstance()->request('WyszukajMiejscowoscWRejestrze',
195
            [
196
                'nazwa'              => $name,
197
                'rodzajMiejscowosci' => $cityTypeName,
198
                'symbol'             => $cityId,
199
                'identyfiks'         => $identyfiks,
200
            ])
201
        ;
202
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaMiejscowosc') as $p) {
203
            $answer[] = new WyszukanaMiejscowosc($p);
204
        };
205
206
        return $answer;
207
    }
208
209
    /**
210
     * Wyszukuje wskazaną ulicę w katalogu ULIC
211
     *
212
     * @param string|null $name         Nazwa ulicy
213
     * @param string      $identityName Nazwa cechy, wymagane
214
     * @param string|null $streetId     ID ulicy
215
     * @param array       $tSimc        Lista cityId w których szukamy
216
     * @param array       $tTerc        Lista tercId w których szukamy
217
     *
218
     * @return WyszukanaUlica[]
219
     */
220 View Code Duplication
    public static 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...
221
        string $name = null,
222
        string $identityName = 'ul.',
223
        string $streetId = null,
224
        array $tSimc = [],
225
        array $tTerc = []
226
    ) {
227
        $answer     = [];
228
        $identyfiks = [];
229
        foreach ($tSimc as $simc) {
230
            $identyfiks[] = ['simc' => $simc];
231
        }
232
        foreach ($tTerc as $terc) {
233
            $identyfiks[] = ['terc' => $terc];
234
        }
235
        $res = Client::getInstance()->request('WyszukajUliceWRejestrze',
236
            [
237
                'nazwa'         => $name,
238
                'cecha'         => $identityName,
239
                'identyfikator' => $streetId,
240
                'identyfiks'    => $identyfiks,
241
            ])
242
        ;
243
        foreach (Helper::getPropertyAsArray($res, 'WyszukanaUlica') as $p) {
244
            $answer[] = new WyszukanaUlica($p);
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\WyszukanaUlica was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
245
        };
246
247
        return $answer;
248
    }
249
}
250