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

Api   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 102
Duplicated Lines 27.45 %

Importance

Changes 0
Metric Value
wmc 9
dl 28
loc 102
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A CzyZalogowany() 0 5 1
A PobierzDateAktualnegoKatNTS() 8 8 2
A PobierzDateAktualnegoKatSimc() 8 8 2
A PobierzDateAktualnegoKatUlic() 8 8 2
A PobierzDateAktualnegoKatTerc() 0 8 2

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: 06.09.2017
17
 * Time: 19:47
18
 */
19
20
namespace mrcnpdlk\Teryt;
21
22
use mrcnpdlk\Teryt\Model\Terc;
23
use mrcnpdlk\Teryt\ResponseModel\Dictionary\RodzajMiejscowosci;
24
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaNomenklaturyNTS;
25
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaPodzialuTerytorialnego;
26
use mrcnpdlk\Teryt\ResponseModel\Territory\JednostkaTerytorialna;
27
use mrcnpdlk\Teryt\ResponseModel\Territory\Miejscowosc;
28
use mrcnpdlk\Teryt\ResponseModel\Territory\Ulica;
29
use mrcnpdlk\Teryt\ResponseModel\Territory\UlicaDrzewo;
30
use mrcnpdlk\Teryt\ResponseModel\Territory\WyszukanaMiejscowosc;
31
use mrcnpdlk\Teryt\ResponseModel\Territory\WyszukanaUlica;
32
use mrcnpdlk\Teryt\ResponseModel\Territory\ZweryfikowanyAdres;
33
use mrcnpdlk\Teryt\ResponseModel\Territory\ZweryfikowanyAdresBezUlic;
34
35
/**
36
 * Class Api
37
 *
38
 * @package mrcnpdlk\Teryt
39
 */
40
class Api
41
{
42
43
    /**
44
     * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
45
     */
46
    const CATEGORY_ALL         = '0'; // Wyszukiwanie wśród wszystkich rodzajów jednostek
47
    const CATEGORY_WOJ_ALL     = '1'; // Dla województw
48
    const CATEGORY_POW_ALL     = '2'; // Dla wszystkich powiatów
49
    const CATEGORY_POW_ZIE     = '21'; // Dla powiatów ziemskich (identyfikator powiatu 01-60)
50
    const CATEGORY_POW_MIA     = '22'; // Dla miast na prawach powiatu (identyfikator powiatu 61-99)
51
    const CATEGORY_GMI_ALL     = '3'; // Dla gmin ogółem
52
    const CATEGORY_GMI_MIA     = '31'; // Dla gmin miejskich (identyfikator rodzaju gminy 1)
53
    const CATEGORY_DELEG       = '32'; // Dla dzielnic i delegatur (identyfikator rodzaju 8 i 9)
54
    const CATEGORY_GMI_WIE     = '33'; // Dla gmin wiejskich (identyfikator rodzaju 2)
55
    const CATEGORY_GMI_MIE_WIE = '34'; // Dla gmin miejsko-wiejskich (3)
56
    const CATEGORY_MIA         = '341'; // Dla miast w gminach miejsko-wiejskich(4)
57
    const CATEGORY_MIA_OBS     = '342'; // Dla obszarów miejskich w gminach miejsko-wiejskich(5)
58
    const CATEGORY_MIA_ALL     = '35'; // Dla miast ogółem (identyfikator 1 i 4)
59
    const CATEGORY_WIE         = '36'; // Dla terenów wiejskich (identyfikator 2 i 5)
60
61
    /**
62
     * Określenie zakresu miejscowości
63
     */
64
65
    const SEARCH_CITY_TYPE_ALL  = '000'; //Wszystkie
66
    const SEARCH_CITY_TYPE_MAIN = '001'; //Miejscowości podstawowe
67
    const SEARCH_CITY_TYPE_ADD  = '002'; //Części integralne miejscowości
68
69
    /**
70
     * Sprawdzenie czy użytkownik jest zalogowany
71
     *
72
     * @return bool
73
     */
74
    public static function CzyZalogowany()
75
    {
76
        $res = Client::getInstance()->request('CzyZalogowany');
77
78
        return $res;
79
    }
80
81
    /**
82
     * Data początkowa bieżącego stanu katalogu TERC
83
     *
84
     * @return null|string Data w formacie YYY-MM-DD
85
     */
86
    public static function PobierzDateAktualnegoKatTerc()
87
    {
88
        $res = Client::getInstance()->request('PobierzDateAktualnegoKatTerc');
89
90
        try {
91
            return (new \DateTime($res))->format('Y-m-d');
92
        } catch (\Exception $e) {
93
            return null;
94
        }
95
    }
96
97
    /**
98
     * Data początkowa bieżącego stanu katalogu NTS
99
     *
100
     * @return null|string Data w formacie YYY-MM-DD
101
     */
102 View Code Duplication
    public static function PobierzDateAktualnegoKatNTS()
1 ignored issue
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...
103
    {
104
        $res = Client::getInstance()->request('PobierzDateAktualnegoKatNTS');
105
106
        try {
107
            return (new \DateTime($res))->format('Y-m-d');
108
        } catch (\Exception $e) {
109
            return null;
110
        }
111
    }
112
113
    /**
114
     * Data początkowa bieżącego stanu katalogu SIMC
115
     *
116
     * @return null|string Data w formacie YYY-MM-DD
117
     */
118 View Code Duplication
    public static function PobierzDateAktualnegoKatSimc()
1 ignored issue
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...
119
    {
120
        $res = Client::getInstance()->request('PobierzDateAktualnegoKatSimc');
121
122
        try {
123
            return (new \DateTime($res))->format('Y-m-d');
124
        } catch (\Exception $e) {
125
            return null;
126
        }
127
    }
128
129
    /**
130
     * Data początkowa bieżącego stanu katalogu ULIC
131
     *
132
     * @return null|string Data w formacie YYY-MM-DD
133
     */
134 View Code Duplication
    public static function PobierzDateAktualnegoKatUlic()
1 ignored issue
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...
135
    {
136
        $res = Client::getInstance()->request('PobierzDateAktualnegoKatUlic');
137
138
        try {
139
            return (new \DateTime($res))->format('Y-m-d');
140
        } catch (\Exception $e) {
141
            return null;
142
        }
143
    }
144
}
145