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