Skip to content

Commit d7eaf2c

Browse files
committed
Data: add property PSU
1 parent e97d700 commit d7eaf2c

File tree

10 files changed

+179
-9
lines changed

10 files changed

+179
-9
lines changed

src/Ares.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ protected function processXml(\SimpleXMLElement $xml, DataProvider $dataProvider
122122
->setCityDistrict(self::exists($xml->AA, 'NCO'))
123123
->setIsPerson(self::exists($xml->PF, 'KPF'))
124124
->setCreated((string) $xml->DV)
125-
->setNace(self::existsArray($xml->Nace, 'NACE'));
125+
->setNace(self::existsArray($xml->Nace, 'NACE'))
126+
->setPSU((string) $xml->PSU);
126127

127128
$dataProvider->setDissolved(isset($xml->DZ) ? (string) $xml->DZ : null);
128129

src/Data/Data.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class Data implements \JsonSerializable
4545
*/
4646
public array $nace = [];
4747

48+
public string $psu = '';
49+
4850

4951
/**
5052
* @param array<string, string|null> $map
@@ -71,6 +73,15 @@ public function toArray(array $map = []): array
7173
}
7274

7375

76+
/**
77+
* @param SubjectFlag::* $index
78+
*/
79+
public function psu(int $index): string
80+
{
81+
return substr($this->psu, $index, 1);
82+
}
83+
84+
7485
/**
7586
* @return array<string, scalar|array<string>>
7687
*/

src/Data/DataProvider.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ public function setIsPerson(string $s)
126126
}
127127

128128

129+
/**
130+
* Příznaky subjektu - NAAANANNNNNNNNNNNNNNPNNNANNNNN
131+
* @see https://wwwinfo.mfcr.cz/ares/ares_xml_standard.html.cz
132+
*
133+
* @return static
134+
*/
135+
public function setPSU(string $psu)
136+
{
137+
$this->data->psu = $psu;
138+
139+
return $this;
140+
}
141+
142+
129143
private function setFileNumberAndCourt(): void
130144
{
131145
$this->data->court_all = null;

src/Data/SubjectFlag.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace h4kuna\Ares\Data;
4+
5+
/**
6+
* Indexation is from 0
7+
*/
8+
final class SubjectFlag
9+
{
10+
public const VR_2 = 1;
11+
public const RES_3 = 2;
12+
public const RZP_4 = 3;
13+
public const NRPZS_5 = 4;
14+
public const RPDPH_6 = 5;
15+
public const RPSD_7 = 6;
16+
public const CEU_K_9 = 8;
17+
public const CEU_V_10 = 9;
18+
public const CEDR_11 = 10;
19+
public const ARIS_12 = 11;
20+
public const RCNS_14 = 13;
21+
public const SPSH_15 = 14;
22+
public const ZR_21 = 20;
23+
public const IR_22 = 21;
24+
public const RSSZ_23 = 22;
25+
public const RO_25 = 24;
26+
27+
}

tests/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
function loadResult(string $name, string $save = ''): \stdClass
5+
function loadResult(string $name, \stdClass $save = null): \stdClass
66
{
77
$file = __DIR__ . "/fixtures/response/$name.json";
8-
if ($save !== '') {
9-
file_put_contents($file, $save);
8+
if ($save !== null) {
9+
file_put_contents($file, json_encode($save, JSON_PRETTY_PRINT));
1010
}
1111

1212
return json_decode(file_get_contents($file));
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
{"in":"25596641","tin":null,"vat_payer":false,"company":"ZERO Brno s.r.o.","zip":"60300","street":"K\u0159\u00eddlovick\u00e1","city":"Brno","house_number":"943\/24a","city_post":"Brno-st\u0159ed","city_district":"Star\u00e9 Brno","is_person":false,"legal_form_code":112,"created":"2000-04-13T00:00:00+02:00","nace":[],"dissolved":"2009-05-26T00:00:00+02:00","active":false,"file_number":null,"court":null,"court_all":null}
1+
{
2+
"active": false,
3+
"city": "Brno",
4+
"company": "ZERO Brno s.r.o.",
5+
"court": null,
6+
"created": "2000-04-13T00:00:00+02:00",
7+
"dissolved": "2009-05-26T00:00:00+02:00",
8+
"file_number": null,
9+
"city_district": "Star\u00e9 Brno",
10+
"city_post": "Brno-st\u0159ed",
11+
"court_all": null,
12+
"in": "25596641",
13+
"is_person": false,
14+
"legal_form_code": 112,
15+
"house_number": "943\/24a",
16+
"street": "K\u0159\u00eddlovick\u00e1",
17+
"tin": null,
18+
"vat_payer": false,
19+
"zip": "60300",
20+
"nace": [],
21+
"psu": "NZHHNNNNZNNNNNNNNNNNNNNNZNNNNN"
22+
}
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
{"in":"26713250","tin":"CZ26713250","vat_payer":true,"company":"BARVY FRAMAR s.r.o.","zip":"14300","street":"Barrandova","city":"Praha","house_number":"1213\/4","city_post":"Praha 12","city_district":"Mod\u0159any","is_person":false,"legal_form_code":112,"created":"2002-08-03T00:00:00+02:00","nace":["20120","433","46380","4778","68320"],"active":true,"dissolved":null,"file_number":"C 89035","court":"M\u011bstsk\u00fd soud v Praze","court_all":"C 89035, M\u011bstsk\u00fd soud v Praze"}
1+
{
2+
"active": true,
3+
"city": "Praha",
4+
"company": "BARVY FRAMAR s.r.o.",
5+
"court": "M\u011bstsk\u00fd soud v Praze",
6+
"created": "2002-08-03T00:00:00+02:00",
7+
"dissolved": null,
8+
"file_number": "C 89035",
9+
"city_district": "Mod\u0159any",
10+
"city_post": "Praha 12",
11+
"court_all": "C 89035, M\u011bstsk\u00fd soud v Praze",
12+
"in": "26713250",
13+
"is_person": false,
14+
"legal_form_code": 112,
15+
"house_number": "1213\/4",
16+
"street": "Barrandova",
17+
"tin": "CZ26713250",
18+
"vat_payer": true,
19+
"zip": "14300",
20+
"nace": [
21+
"20120",
22+
"433",
23+
"46380",
24+
"4778",
25+
"68320"
26+
],
27+
"psu": "NAAANANNNNANNNNNNNNNNNNNANNNNN"
28+
}
Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
{"active":true,"city":"Praha","company":"Alza.cz a.s.","court":"M\u011bstsk\u00fd soud v Praze","created":"2003-08-26T00:00:00+02:00","dissolved":null,"file_number":"B 8573","city_district":"Hole\u0161ovice","city_post":"Praha 7","court_all":"B 8573, M\u011bstsk\u00fd soud v Praze","in":"27082440","is_person":false,"legal_form_code":121,"house_number":"1522\/53","street":"Jankovcova","tin":"CZ27082440","vat_payer":true,"zip":"17000","nace":["26110","26300","27900","33140","461","46900","471","49410","56100","620","6492","731"]}
1+
{
2+
"active": true,
3+
"city": "Praha",
4+
"company": "Alza.cz a.s.",
5+
"court": "M\u011bstsk\u00fd soud v Praze",
6+
"created": "2003-08-26T00:00:00+02:00",
7+
"dissolved": null,
8+
"file_number": "B 8573",
9+
"city_district": "Hole\u0161ovice",
10+
"city_post": "Praha 7",
11+
"court_all": "B 8573, M\u011bstsk\u00fd soud v Praze",
12+
"in": "27082440",
13+
"is_person": false,
14+
"legal_form_code": 121,
15+
"house_number": "1522\/53",
16+
"street": "Jankovcova",
17+
"tin": "CZ27082440",
18+
"vat_payer": true,
19+
"zip": "17000",
20+
"nace": [
21+
"26110",
22+
"26300",
23+
"27900",
24+
"33140",
25+
"461",
26+
"46900",
27+
"471",
28+
"47250",
29+
"49410",
30+
"56100",
31+
"620",
32+
"6492",
33+
"731"
34+
],
35+
"psu": "NAAANANNNNNNNNNNNNNNPNNNANNNNN"
36+
}
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
{"in":"87744473","tin":"CZ8612301071","vat_payer":true,"company":"Milan Mat\u011bj\u010dek","zip":"29404","street":"Dubov\u00e1","city":"Doln\u00ed Bousov","house_number":"765","city_post":null,"city_district":"Doln\u00ed Bousov","is_person":true,"legal_form_code":101,"created":"2011-04-04T00:00:00+02:00","nace":["461","471","620","73110","7490"],"active":true,"dissolved":null,"file_number":null,"court":null,"court_all":null}
1+
{
2+
"active": true,
3+
"city": "Doln\u00ed Bousov",
4+
"company": "Milan Mat\u011bj\u010dek",
5+
"court": null,
6+
"created": "2011-04-04T00:00:00+02:00",
7+
"dissolved": null,
8+
"file_number": null,
9+
"city_district": "Doln\u00ed Bousov",
10+
"city_post": null,
11+
"court_all": null,
12+
"in": "87744473",
13+
"is_person": true,
14+
"legal_form_code": 101,
15+
"house_number": "765",
16+
"street": "Dubov\u00e1",
17+
"tin": "CZ8612301071",
18+
"vat_payer": true,
19+
"zip": "29404",
20+
"nace": [
21+
"461",
22+
"471",
23+
"620",
24+
"73110",
25+
"7490"
26+
],
27+
"psu": "NNAANANNNNNNNNNNNNNNNNNNANNNNN"
28+
}

tests/src/AresTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ public function testFreelancer(): void
2626
{
2727
$ares = (new Ares\AresFactory())->create();
2828
$in = '87744473';
29-
$data = json_decode((string) $ares->loadData($in));
29+
$aresData = $ares->loadData($in);
30+
$data = json_decode((string) $aresData);
3031
Assert::equal(loadResult($in), $data);
32+
33+
Assert::same('N', $aresData->psu(Ares\Data\SubjectFlag::VR_2));
34+
Assert::same('A', $aresData->psu(Ares\Data\SubjectFlag::RES_3));
35+
Assert::same('A', $aresData->psu(Ares\Data\SubjectFlag::RZP_4));
36+
Assert::same('N', $aresData->psu(Ares\Data\SubjectFlag::NRPZS_5));
37+
Assert::same('A', $aresData->psu(Ares\Data\SubjectFlag::RPDPH_6));
3138
}
3239

3340

0 commit comments

Comments
 (0)