SearchReport::getPostCity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GusApi;
6
7
use GusApi\Type\Response\SearchResponseCompanyData;
8
use JsonSerializable;
9
10
class SearchReport implements JsonSerializable
11
{
12
    public const TYPE_JURIDICAL_PERSON = 'p';
13
14
    public const TYPE_NATURAL_PERSON = 'f';
15
16
    public const TYPE_LOCAL_ENTITY_JURIDICAL_PERSON = 'lp';
17
18
    public const TYPE_LOCAL_ENTITY_NATURAL_PERSON = 'lf';
19
20
    private string $regon;
21
22
    private string $nip;
23
24
    private string $nipStatus;
25
26
    private string $regon14;
27
28
    private string $name;
29
30
    private string $province;
31
32
    private string $district;
33
34
    private string $community;
35
36
    private string $city;
37
38
    private string $propertyNumber;
39
40
    private string $apartmentNumber;
41
42
    private string $zipCode;
43
44
    private string $street;
45
46
    private string $type;
47
48
    private int $silo;
49
50
    private string $activityEndDate;
51
52
    private string $postCity;
53
54
    public function __construct(SearchResponseCompanyData $data)
55
    {
56
        $this->regon = $data->getRegon();
57
        $this->nip = $data->getNip();
58
        $this->nipStatus = $data->getStatusNip();
59
        $this->name = $data->getNazwa();
60
        $this->province = $data->getWojewodztwo();
61
        $this->district = $data->getPowiat();
62
        $this->community = $data->getGmina();
63
        $this->city = $data->getMiejscowosc();
64
        $this->zipCode = $data->getKodPocztowy();
65
        $this->street = $data->getUlica();
66
        $this->propertyNumber = $data->getNrNieruchomosci();
67
        $this->apartmentNumber = $data->getNrLokalu();
68
        $this->type = $this->makeType($data->getTyp());
69
        $this->regon14 = $this->makeRegon14($this->getRegon());
70
        $this->silo = (int) $data->getSilosID();
71
        $this->activityEndDate = $data->getDataZakonczeniaDzialalnosci();
72
        $this->postCity = $data->getMiejscowoscPoczty();
73
    }
74
75
    public function getRegon(): string
76
    {
77
        return $this->regon;
78
    }
79
80
    public function getName(): string
81
    {
82
        return $this->name;
83
    }
84
85
    public function getProvince(): string
86
    {
87
        return $this->province;
88
    }
89
90
    public function getDistrict(): string
91
    {
92
        return $this->district;
93
    }
94
95
    public function getCommunity(): string
96
    {
97
        return $this->community;
98
    }
99
100
    public function getCity(): string
101
    {
102
        return $this->city;
103
    }
104
105
    public function getZipCode(): string
106
    {
107
        return $this->zipCode;
108
    }
109
110
    public function getStreet(): string
111
    {
112
        return $this->street;
113
    }
114
115
    public function getType(): string
116
    {
117
        return $this->type;
118
    }
119
120
    public function getRegon14(): string
121
    {
122
        return $this->regon14;
123
    }
124
125
    public function getSilo(): int
126
    {
127
        return $this->silo;
128
    }
129
130
    public function getNip(): string
131
    {
132
        return $this->nip;
133
    }
134
135
    public function getNipStatus(): string
136
    {
137
        return $this->nipStatus;
138
    }
139
140
    public function getPropertyNumber(): string
141
    {
142
        return $this->propertyNumber;
143
    }
144
145
    public function getApartmentNumber(): string
146
    {
147
        return $this->apartmentNumber;
148
    }
149
150
    public function getActivityEndDate(): string
151
    {
152
        return $this->activityEndDate;
153
    }
154
155
    public function getPostCity(): string
156
    {
157
        return $this->postCity;
158
    }
159
160
    private function makeRegon14(string $regon): string
161
    {
162
        return str_pad($regon, 14, '0');
163
    }
164
165
    private function makeType(string $type): string
166
    {
167
        return trim(strtolower($type));
168
    }
169
170
    public function jsonSerialize(): array
171
    {
172
        return get_object_vars($this);
173
    }
174
}
175