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 Pudełek <[email protected]> |
16
|
|
|
* Date: 06.09.2017 |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace mrcnpdlk\Teryt\ResponseModel\Territory; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
use mrcnpdlk\Teryt\Model\Terc; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class AbstractResponseModel |
26
|
|
|
* |
27
|
|
|
* @package mrcnpdlk\Teryt\ResponseModel\Territory |
28
|
|
|
*/ |
29
|
|
|
abstract class AbstractResponseModel |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Dwuznakowy symbol województwa |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
public $provinceId; |
37
|
|
|
/** |
38
|
|
|
* Dwuznakowy symbol powiatu |
39
|
|
|
* |
40
|
|
|
* @var string|null |
41
|
|
|
*/ |
42
|
|
|
public $districtId; |
43
|
|
|
/** |
44
|
|
|
* Dwuznakowy symbol gminy |
45
|
|
|
* |
46
|
|
|
* @var string|null |
47
|
|
|
*/ |
48
|
|
|
public $communeId; |
49
|
|
|
/** |
50
|
|
|
* Jednoznakowy symbol gminy |
51
|
|
|
* |
52
|
|
|
* @var string|null |
53
|
|
|
*/ |
54
|
|
|
public $communeTypeId; |
55
|
|
|
/** |
56
|
|
|
* Nazwa województwa |
57
|
|
|
* |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
public $provinceName; |
61
|
|
|
/** |
62
|
|
|
* Nazwa powiatu |
63
|
|
|
* |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
public $districtName; |
67
|
|
|
/** |
68
|
|
|
* Nazwa gminy |
69
|
|
|
* |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
public $communeName; |
73
|
|
|
/** |
74
|
|
|
* Nazwa rodzaju gminy |
75
|
|
|
* |
76
|
|
|
* @var string|null |
77
|
|
|
*/ |
78
|
|
|
public $communeTypeName; |
79
|
|
|
/** |
80
|
|
|
* Określa datę katalogu dla wskazanego stanu w formacie YYYY-MM-DD |
81
|
|
|
* |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
public $statusDate; |
85
|
|
|
/** |
86
|
|
|
* Identyfikator gminy wraz z RODZ |
87
|
|
|
* |
88
|
|
|
* @var integer |
89
|
|
|
*/ |
90
|
|
|
public $tercId; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* AbstractResponseModel constructor. |
94
|
|
|
* |
95
|
|
|
* @param \stdClass|null $oData |
96
|
|
|
*/ |
97
|
|
|
public function __construct(\stdClass $oData = null) |
|
|
|
|
98
|
|
|
{ |
99
|
|
|
$this->expandData(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Dociągnięcie informacji na pozostałe pola obiektu |
104
|
|
|
* |
105
|
|
|
* @return $this |
106
|
|
|
*/ |
107
|
|
|
public function expandData() |
108
|
|
|
{ |
109
|
|
|
if ($this->tercId) { |
110
|
|
|
$oTerc = new Terc($this->tercId); |
111
|
|
|
$this->provinceId = $oTerc->getProvinceId(); |
112
|
|
|
$this->districtId = $oTerc->getDistrictId(); |
113
|
|
|
$this->communeId = $oTerc->getCommuneId(); |
114
|
|
|
$this->communeTypeId = $oTerc->getCommuneTypeId(); |
115
|
|
|
} else { |
116
|
|
|
if ($this->provinceId && $this->districtId && $this->communeId && $this->communeTypeId) { |
|
|
|
|
117
|
|
|
$oTerc = (new Terc())->setIds($this->provinceId, $this->districtId, $this->communeId, $this->communeTypeId); |
118
|
|
|
$this->tercId = $oTerc->getTercId(); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
$this->clearData(); |
123
|
|
|
|
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Clearing empty value |
129
|
|
|
* |
130
|
|
|
* @return $this |
131
|
|
|
*/ |
132
|
|
|
public function clearData() |
133
|
|
|
{ |
134
|
|
|
//clearing data |
135
|
|
|
foreach (get_object_vars($this) as $prop => $value) { |
136
|
|
|
if ($value === '') { |
137
|
|
|
$this->{$prop} = null; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.