Code Duplication    Length = 27-29 lines in 3 locations

src/mrcnpdlk/Teryt/Api/Search.php 3 locations

@@ 139-165 (lines=27) @@
136
     *
137
     * @return JednostkaPodzialuTerytorialnego[]
138
     */
139
    public static function WyszukajJednostkeWRejestrze(
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,
157
                'identyfiks' => $identyfiks,
158
            ])
159
        ;
160
        foreach (Helper::getPropertyAsArray($res, 'JednostkaPodzialuTerytorialnego') as $p) {
161
            $answer[] = new JednostkaPodzialuTerytorialnego($p);
162
        };
163
164
        return $answer;
165
    }
166
167
    /**
168
     * Zwaraca listę znalezionych miejscowości we wskazanej
@@ 179-207 (lines=29) @@
176
     *
177
     * @return WyszukanaMiejscowosc[]
178
     */
179
    public static function WyszukajMiejscowoscWRejestrze(
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
@@ 220-248 (lines=29) @@
217
     *
218
     * @return WyszukanaUlica[]
219
     */
220
    public static function WyszukajUliceWRejestrze(
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);
245
        };
246
247
        return $answer;
248
    }
249
}
250