1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Defr\Ares; |
4
|
|
|
|
5
|
|
|
use Defr\Justice; |
6
|
|
|
use Defr\ValueObject\Person; |
7
|
|
|
use Goutte\Client as GouteClient; |
8
|
|
|
use GuzzleHttp\Client as GuzzleClient; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class AresRecord. |
12
|
|
|
* |
13
|
|
|
* @author Dennis Fridrich <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class AresRecord |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var int |
19
|
|
|
*/ |
20
|
|
|
private $companyId; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $taxId; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
private $companyName; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $street; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $streetHouseNumber; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $streetOrientationNumber; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
private $town; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $zip; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var null|GouteClient |
59
|
|
|
*/ |
60
|
|
|
protected $client; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* AresRecord constructor. |
64
|
|
|
* |
65
|
|
|
* @param null $companyId |
66
|
|
|
* @param null $taxId |
67
|
|
|
* @param null $companyName |
68
|
|
|
* @param null $street |
69
|
|
|
* @param null $streetHouseNumber |
70
|
|
|
* @param null $streetOrientationNumber |
71
|
|
|
* @param null $town |
72
|
|
|
* @param null $zip |
73
|
|
|
*/ |
74
|
2 |
|
public function __construct( |
75
|
|
|
$companyId = null, |
76
|
|
|
$taxId = null, |
77
|
|
|
$companyName = null, |
78
|
|
|
$street = null, |
79
|
|
|
$streetHouseNumber = null, |
80
|
|
|
$streetOrientationNumber = null, |
81
|
|
|
$town = null, |
82
|
|
|
$zip = null |
83
|
|
|
) { |
84
|
2 |
|
$this->companyId = $companyId; |
85
|
2 |
|
$this->taxId = !empty($taxId) ? $taxId : null; |
86
|
2 |
|
$this->companyName = $companyName; |
87
|
2 |
|
$this->street = $street; |
88
|
2 |
|
$this->streetHouseNumber = !empty($streetHouseNumber) ? $streetHouseNumber : null; |
89
|
2 |
|
$this->streetOrientationNumber = !empty($streetOrientationNumber) ? $streetOrientationNumber : null; |
90
|
2 |
|
$this->town = $town; |
91
|
2 |
|
$this->zip = $zip; |
92
|
2 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getStreetWithNumbers() |
98
|
|
|
{ |
99
|
|
|
return $this->street.' ' |
100
|
|
|
.($this->streetOrientationNumber |
101
|
|
|
? |
102
|
|
|
$this->streetHouseNumber.'/'.$this->streetOrientationNumber |
103
|
|
|
: |
104
|
|
|
$this->streetHouseNumber); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return mixed |
109
|
|
|
*/ |
110
|
|
|
public function __toString() |
111
|
|
|
{ |
112
|
|
|
return $this->companyName; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return mixed |
117
|
|
|
*/ |
118
|
2 |
|
public function getCompanyId() |
119
|
|
|
{ |
120
|
2 |
|
return $this->companyId; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return mixed |
125
|
|
|
*/ |
126
|
1 |
|
public function getTaxId() |
127
|
|
|
{ |
128
|
1 |
|
return $this->taxId; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return mixed |
133
|
|
|
*/ |
134
|
1 |
|
public function getCompanyName() |
135
|
|
|
{ |
136
|
1 |
|
return $this->companyName; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return mixed |
141
|
|
|
*/ |
142
|
1 |
|
public function getStreet() |
143
|
|
|
{ |
144
|
1 |
|
return $this->street; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return mixed |
149
|
|
|
*/ |
150
|
1 |
|
public function getStreetHouseNumber() |
151
|
|
|
{ |
152
|
1 |
|
return $this->streetHouseNumber; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return mixed |
157
|
|
|
*/ |
158
|
1 |
|
public function getStreetOrientationNumber() |
159
|
|
|
{ |
160
|
1 |
|
return $this->streetOrientationNumber; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return mixed |
165
|
|
|
*/ |
166
|
1 |
|
public function getTown() |
167
|
|
|
{ |
168
|
1 |
|
return $this->town; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
1 |
|
public function getZip() |
175
|
|
|
{ |
176
|
1 |
|
return $this->zip; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param GouteClient $client |
181
|
|
|
* |
182
|
|
|
* @return $this |
183
|
|
|
*/ |
184
|
|
|
public function setClient(GouteClient $client) |
185
|
|
|
{ |
186
|
|
|
$this->client = $client; |
187
|
|
|
|
188
|
|
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return GouteClient |
193
|
|
|
*/ |
194
|
|
|
public function getClient() |
195
|
|
|
{ |
196
|
|
|
if (!$this->client) { |
197
|
|
|
$this->client = new GouteClient(); |
198
|
|
|
$this->client->setClient(new GuzzleClient(['verify' => false])); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
return $this->client; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return array|Person[] |
206
|
|
|
*/ |
207
|
|
|
public function getCompanyPeople() |
208
|
|
|
{ |
209
|
|
|
$client = $this->getClient(); |
210
|
|
|
$justice = new Justice($client); |
211
|
|
|
$justiceRecord = $justice->findById($this->companyId); |
212
|
|
|
if ($justiceRecord) { |
213
|
|
|
return $justiceRecord->getPeople(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
return []; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @param int $companyId |
221
|
|
|
*/ |
222
|
2 |
|
public function setCompanyId($companyId) |
223
|
|
|
{ |
224
|
2 |
|
$this->companyId = $companyId; |
225
|
2 |
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @param string $taxId |
229
|
|
|
*/ |
230
|
2 |
|
public function setTaxId($taxId) |
231
|
|
|
{ |
232
|
2 |
|
$this->taxId = $taxId; |
233
|
2 |
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @param string $companyName |
237
|
|
|
*/ |
238
|
2 |
|
public function setCompanyName($companyName) |
239
|
|
|
{ |
240
|
2 |
|
$this->companyName = $companyName; |
241
|
2 |
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param string $street |
245
|
|
|
*/ |
246
|
2 |
|
public function setStreet($street) |
247
|
|
|
{ |
248
|
2 |
|
$this->street = $street; |
249
|
2 |
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @param string $streetHouseNumber |
253
|
|
|
*/ |
254
|
2 |
|
public function setStreetHouseNumber($streetHouseNumber) |
255
|
|
|
{ |
256
|
2 |
|
$this->streetHouseNumber = $streetHouseNumber; |
257
|
2 |
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @param string $streetOrientationNumber |
261
|
|
|
*/ |
262
|
1 |
|
public function setStreetOrientationNumber($streetOrientationNumber) |
263
|
|
|
{ |
264
|
1 |
|
$this->streetOrientationNumber = $streetOrientationNumber; |
265
|
1 |
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @param string $town |
269
|
|
|
*/ |
270
|
2 |
|
public function setTown($town) |
271
|
|
|
{ |
272
|
2 |
|
$this->town = $town; |
273
|
2 |
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param string $zip |
277
|
|
|
*/ |
278
|
2 |
|
public function setZip($zip) |
279
|
|
|
{ |
280
|
2 |
|
$this->zip = $zip; |
281
|
2 |
|
} |
282
|
|
|
} |
283
|
|
|
|