GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#153)
by joseph
14:08
created

AddressEmbeddable   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 289
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 95
dl 0
loc 289
ccs 0
cts 166
cp 0
rs 10
c 0
b 0
f 0
wmc 20

19 Methods

Rating   Name   Duplication   Size   Complexity  
A getHouseNumber() 0 3 1
A __toString() 0 15 1
A create() 0 15 2
A getPrefix() 0 3 1
A getCity() 0 3 1
A setCountryCode() 0 10 1
A __construct() 0 16 1
A setHouseNumber() 0 10 1
A getHouseName() 0 3 1
A setCity() 0 10 1
A setStreet() 0 10 1
A getStreet() 0 3 1
A getPostalArea() 0 3 1
A getCountryCode() 0 3 1
A loadMetadata() 0 14 1
A getPostalCode() 0 3 1
A setPostalArea() 0 10 1
A setPostalCode() 0 10 1
A setHouseName() 0 10 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Geo;
4
5
use Doctrine\ORM\Mapping\ClassMetadata;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Geo\HasAddressEmbeddableInterface;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Geo\AddressEmbeddableInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\AbstractEmbeddableObject;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
11
class AddressEmbeddable extends AbstractEmbeddableObject implements AddressEmbeddableInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $houseNumber;
17
    /**
18
     * @var string
19
     */
20
    private $houseName;
21
    /**
22
     * @var string
23
     */
24
    private $street;
25
    /**
26
     * @var string
27
     */
28
    private $city;
29
    /**
30
     * @var string
31
     */
32
    private $countryCode;
33
    /**
34
     * @var string
35
     */
36
    private $postalCode;
37
    /**
38
     * @var string
39
     */
40
    private $postalArea;
41
42
    public function __construct(
43
        string $houseNumber,
44
        string $houseName,
45
        string $street,
46
        string $city,
47
        string $postalArea,
48
        string $postalCode,
49
        string $countryCode
50
    ) {
51
        $this->setHouseNumber($houseNumber);
52
        $this->setHouseName($houseName);
53
        $this->setStreet($street);
54
        $this->setCity($city);
55
        $this->setPostalArea($postalArea);
56
        $this->setPostalCode($postalCode);
57
        $this->setCountryCode($countryCode);
58
    }
59
60
    /**
61
     * @param string $houseNumber
62
     *
63
     * @return AddressEmbeddable
64
     */
65
    private function setHouseNumber(string $houseNumber): AddressEmbeddableInterface
66
    {
67
        $this->notifyEmbeddablePrefixedProperties(
68
            'houseNumber',
69
            $this->houseNumber,
70
            $houseNumber
71
        );
72
        $this->houseNumber = $houseNumber;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @param string $houseName
79
     *
80
     * @return AddressEmbeddable
81
     */
82
    private function setHouseName(string $houseName): AddressEmbeddableInterface
83
    {
84
        $this->notifyEmbeddablePrefixedProperties(
85
            'houseName',
86
            $this->houseName,
87
            $houseName
88
        );
89
        $this->houseName = $houseName;
90
91
        return $this;
92
    }
93
94
    /**
95
     * @param string $street
96
     *
97
     * @return AddressEmbeddable
98
     */
99
    private function setStreet(string $street): AddressEmbeddableInterface
100
    {
101
        $this->notifyEmbeddablePrefixedProperties(
102
            'street',
103
            $this->street,
104
            $street
105
        );
106
        $this->street = $street;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @param string $city
113
     *
114
     * @return AddressEmbeddable
115
     */
116
    private function setCity(string $city): AddressEmbeddableInterface
117
    {
118
        $this->notifyEmbeddablePrefixedProperties(
119
            'city',
120
            $this->city,
121
            $city
122
        );
123
        $this->city = $city;
124
125
        return $this;
126
    }
127
128
    /**
129
     * @param string $countryCode
130
     *
131
     * @return AddressEmbeddable
132
     */
133
    private function setCountryCode(string $countryCode): AddressEmbeddableInterface
134
    {
135
        $this->notifyEmbeddablePrefixedProperties(
136
            'countryCode',
137
            $this->countryCode,
138
            $countryCode
139
        );
140
        $this->countryCode = $countryCode;
141
142
        return $this;
143
    }
144
145
    /**
146
     * @param string $postalCode
147
     *
148
     * @return AddressEmbeddable
149
     */
150
    private function setPostalCode(string $postalCode): AddressEmbeddableInterface
151
    {
152
        $this->notifyEmbeddablePrefixedProperties(
153
            'postalCode',
154
            $this->postalCode,
155
            $postalCode
156
        );
157
        $this->postalCode = $postalCode;
158
159
        return $this;
160
    }
161
162
    /**
163
     * @param string $postalArea
164
     *
165
     * @return AddressEmbeddable
166
     */
167
    private function setPostalArea(string $postalArea): AddressEmbeddableInterface
168
    {
169
        $this->notifyEmbeddablePrefixedProperties(
170
            'postalArea',
171
            $this->postalArea,
172
            $postalArea
173
        );
174
        $this->postalArea = $postalArea;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @param ClassMetadata $metadata
181
     * @SuppressWarnings(PHPMD.StaticAccess)
182
     */
183
    public static function loadMetadata(ClassMetadata $metadata): void
184
    {
185
        $builder = self::setEmbeddableAndGetBuilder($metadata);
186
        MappingHelper::setSimpleStringFields(
187
            [
188
                AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER,
189
                AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NAME,
190
                AddressEmbeddableInterface::EMBEDDED_PROP_STREET,
191
                AddressEmbeddableInterface::EMBEDDED_PROP_CITY,
192
                AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_AREA,
193
                AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_CODE,
194
                AddressEmbeddableInterface::EMBEDDED_PROP_COUNTRY_CODE,
195
            ],
196
            $builder
197
        );
198
    }
199
200
    /**
201
     * @param array $properties
202
     *
203
     * @return AddressEmbeddableInterface
204
     */
205
    public static function create(array $properties): AddressEmbeddableInterface
206
    {
207
        if (array_key_exists(AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER, $properties)) {
208
            return new self(
209
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER],
210
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NAME],
211
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_STREET],
212
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_CITY],
213
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_AREA],
214
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_CODE],
215
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_COUNTRY_CODE]
216
            );
217
        }
218
219
        return new self(...array_values($properties));
220
221
    }
222
223
    public function __toString(): string
224
    {
225
        return (string)print_r(
226
            [
227
                'addressEmbeddable' => [
228
                    AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER => $this->getHouseNumber(),
229
                    AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NAME   => $this->getHouseName(),
230
                    AddressEmbeddableInterface::EMBEDDED_PROP_STREET       => $this->getStreet(),
231
                    AddressEmbeddableInterface::EMBEDDED_PROP_CITY         => $this->getCity(),
232
                    AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_AREA  => $this->getPostalArea(),
233
                    AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_CODE  => $this->getPostalCode(),
234
                    AddressEmbeddableInterface::EMBEDDED_PROP_COUNTRY_CODE => $this->getCountryCode(),
235
                ],
236
            ],
237
            true
238
        );
239
    }
240
241
    /**
242
     * @return string
243
     */
244
    public function getHouseNumber(): string
245
    {
246
        return $this->houseNumber ?? '';
247
    }
248
249
    /**
250
     * @return string
251
     */
252
    public function getHouseName(): string
253
    {
254
        return $this->houseName ?? '';
255
    }
256
257
    /**
258
     * @return string
259
     */
260
    public function getStreet(): string
261
    {
262
        return $this->street ?? '';
263
    }
264
265
    /**
266
     * @return string
267
     */
268
    public function getCity(): string
269
    {
270
        return $this->city ?? '';
271
    }
272
273
    /**
274
     * @return string
275
     */
276
    public function getPostalCode(): string
277
    {
278
        return $this->postalCode ?? '';
279
    }
280
281
    /**
282
     * @return string
283
     */
284
    public function getPostalArea(): string
285
    {
286
        return $this->postalArea ?? '';
287
    }
288
289
    /**
290
     * @return string
291
     */
292
    public function getCountryCode(): string
293
    {
294
        return $this->countryCode ?? '';
295
    }
296
297
    protected function getPrefix(): string
298
    {
299
        return HasAddressEmbeddableInterface::PROP_ADDRESS_EMBEDDABLE;
300
    }
301
}
302