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

Verification   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 144
Duplicated Lines 50.69 %

Importance

Changes 0
Metric Value
wmc 8
dl 73
loc 144
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A WeryfikujAdresWmiejscowosci() 22 22 2
A WeryfikujAdresDlaMiejscowosciAdresowy() 6 6 1
A WeryfikujAdresWmiejscowosciAdresowy() 22 22 2
A WeryfikujAdresDlaUlic() 6 6 1
A WeryfikujAdresDlaUlicAdresowy() 6 6 1
A WeryfikujAdresDlaMiejscowosci() 6 6 1

How to fix   Duplicated Code   

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:

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:53
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\ZweryfikowanyAdres;
26
use mrcnpdlk\Teryt\ResponseModel\Territory\ZweryfikowanyAdresBezUlic;
27
28
class Verification
29
{
30
    /**
31
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
32
     * miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
33
     *
34
     * @param string $cityId
35
     *
36
     * @return ZweryfikowanyAdresBezUlic
37
     */
38 View Code Duplication
    public static 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...
39
    {
40
        $res   = Client::getInstance()->request('WeryfikujAdresDlaMiejscowosci', ['symbolMsc' => $cityId]);
41
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
42
43
        return new ZweryfikowanyAdresBezUlic($oData);
44
    }
45
46
    /**
47
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT,w wersji
48
     * adresowej rejestru do poziomu miejscowości. Weryfikacja odbywa się za pomoca identyfikatorów
49
     *
50
     * @param string $cityId
51
     *
52
     * @return ZweryfikowanyAdresBezUlic
53
     */
54 View Code Duplication
    public static 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...
55
    {
56
        $res   = Client::getInstance()->request('WeryfikujAdresDlaMiejscowosciAdresowy', ['symbolMsc' => $cityId]);
57
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdresBezUlic');
58
59
        return new ZweryfikowanyAdresBezUlic($oData);
60
    }
61
62
    /**
63
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT do poziomu
64
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
65
     *
66
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
67
     * w wtórym zostanie zwrócona tablica wyników
68
     *
69
     * @param string      $provinceName Nazwa województwa
70
     * @param string      $districtName Nazwa powiatu
71
     * @param string      $communeName  Nazwa gminy
72
     * @param string      $cityName     Nazwa miejscowości
73
     * @param string|null $cityTypeName Nazwa typu miejscowości
74
     *
75
     * @return ZweryfikowanyAdresBezUlic[]
76
     */
77 View Code Duplication
    public static 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...
78
        string $provinceName,
79
        string $districtName,
80
        string $communeName,
81
        string $cityName,
82
        string $cityTypeName = null
83
    ) {
84
        $answer = [];
85
        $res    = Client::getInstance()->request('WeryfikujAdresWmiejscowosci',
86
            [
87
                'Wojewodztwo' => $provinceName,
88
                'Powiat'      => $districtName,
89
                'Gmina'       => $communeName,
90
                'Miejscowosc' => $cityName,
91
                'Rodzaj'      => $cityTypeName,
92
            ])
93
        ;
94
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
95
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
96
        };
97
98
        return $answer;
99
    }
100
101
    /**
102
     * Weryfikuje istnienie wskazanego obiektu w bazie TERYT w wersji adresowej do poziomu
103
     * miejscowości. Weryfikacja odbywa się za pomoca nazw
104
     *
105
     * Nazwa miejscowości nie musibyć pełna - nastąpi wtedy wyszkiwanie pełnokontekstowe
106
     * w wtórym zostanie zwrócona tablica wyników
107
     *
108
     * @param string      $provinceName Nazwa województwa
109
     * @param string      $districtName Nazwa powiatu
110
     * @param string      $communeName  Nazwa gminy
111
     * @param string      $cityName     Nazwa miejscowości
112
     * @param string|null $cityTypeName Nazwa typu miejscowości
113
     *
114
     * @return ZweryfikowanyAdresBezUlic[]
115
     */
116 View Code Duplication
    public static 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...
117
        string $provinceName,
118
        string $districtName,
119
        string $communeName,
120
        string $cityName,
121
        string $cityTypeName = null
122
    ) {
123
        $answer = [];
124
        $res    = Client::getInstance()->request('WeryfikujAdresWmiejscowosciAdresowy',
125
            [
126
                'Wojewodztwo' => $provinceName,
127
                'Powiat'      => $districtName,
128
                'Gmina'       => $communeName,
129
                'Miejscowosc' => $cityName,
130
                'Rodzaj'      => $cityTypeName,
131
            ])
132
        ;
133
        foreach (Helper::getPropertyAsArray($res, 'ZweryfikowanyAdresBezUlic') as $p) {
134
            $answer[] = new ZweryfikowanyAdresBezUlic($p);
135
        };
136
137
        return $answer;
138
    }
139
140
    /**
141
     * Weryfikuje istnienie wskazanego obiektu w bazie
142
     * TERYT do poziomu ulic.Weryfikacja odbywa się za pomoca nazw
143
     *
144
     * @param string $cityId
145
     * @param string $streetId
146
     *
147
     * @return ZweryfikowanyAdres
148
     */
149 View Code Duplication
    public static 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...
150
    {
151
        $res   = Client::getInstance()->request('WeryfikujAdresDlaUlic', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
152
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
153
154
        return new ZweryfikowanyAdres($oData);
155
    }
156
157
    /**
158
     * Weryfikuje istnienie wskazanego obiektu w bazie
159
     * TERYT do poziomu ulic w wersji adresowej. Weryfikacja odbywa się za pomoca nazw
160
     *
161
     * @param string $cityId
162
     * @param string $streetId
163
     *
164
     * @return ZweryfikowanyAdres
165
     */
166 View Code Duplication
    public static 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...
167
    {
168
        $res   = Client::getInstance()->request('WeryfikujAdresDlaUlicAdresowy', ['symbolMsc' => $cityId, 'SymUl' => $streetId]);
169
        $oData = Helper::getPropertyAsObject($res, 'ZweryfikowanyAdres');
170
171
        return new ZweryfikowanyAdres($oData);
172
    }
173
}
174