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

TERC   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A PobierzListeWojewodztw() 0 9 2
A PobierzListePowiatow() 0 9 2
A PobierzGminyiPowDlaWoj() 0 9 2
A PobierzListeGmin() 0 9 2
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:38
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\JednostkaTerytorialna;
26
27
class TERC
28
{
29
    /**
30
     * Lista województw
31
     *
32
     * @return JednostkaTerytorialna[]
33
     */
34
    public static function PobierzListeWojewodztw()
35
    {
36
        $answer = [];
37
        $res    = Client::getInstance()->request('PobierzListeWojewodztw');
38
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
39
            $answer[] = new JednostkaTerytorialna($p);
40
        };
41
42
        return $answer;
43
    }
44
45
    /**
46
     * Pobieranie listy powiatów dla danego województwa
47
     *
48
     * @param string $provinceId
49
     *
50
     * @return JednostkaTerytorialna[]
51
     */
52
    public static function PobierzListePowiatow(string $provinceId)
53
    {
54
        $answer = [];
55
        $res    = Client::getInstance()->request('PobierzListePowiatow', ['Woj' => $provinceId]);
56
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
57
            $answer[] = new JednostkaTerytorialna($p);
58
        };
59
60
        return $answer;
61
    }
62
63
    /**
64
     * Lista gmin we wskazanym powiecie
65
     *
66
     * @param string $provinceId
67
     * @param string $districtId
68
     *
69
     * @return JednostkaTerytorialna[]
70
     */
71
    public static function PobierzListeGmin(string $provinceId, string $districtId)
72
    {
73
        $answer = [];
74
        $res    = Client::getInstance()->request('PobierzListeGmin', ['Woj' => $provinceId, 'Pow' => $districtId]);
75
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
76
            $answer[] = new JednostkaTerytorialna($p);
77
        };
78
79
        return $answer;
80
    }
81
82
    /**
83
     * Lista powiatów i gmin we wskazanym województwie
84
     *
85
     * @param string $provinceId
86
     *
87
     * @return JednostkaTerytorialna[]
88
     */
89
    public static function PobierzGminyiPowDlaWoj(string $provinceId)
90
    {
91
        $answer = [];
92
        $res    = Client::getInstance()->request('PobierzGminyiPowDlaWoj', ['Woj' => $provinceId]);
93
        foreach (Helper::getPropertyAsArray($res, 'JednostkaTerytorialna') as $p) {
94
            $answer[] = new JednostkaTerytorialna($p);
95
        };
96
97
        return $answer;
98
    }
99
}
100