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 (#196)
by joseph
28:03
created

AddressEmbeddable::setHouseNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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 2
    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 2
        $this->setHouseNumber($houseNumber);
52 2
        $this->setHouseName($houseName);
53 2
        $this->setStreet($street);
54 2
        $this->setCity($city);
55 2
        $this->setPostalArea($postalArea);
56 2
        $this->setPostalCode($postalCode);
57 2
        $this->setCountryCode($countryCode);
58 2
    }
59
60
    /**
61
     * @param string $houseNumber
62
     *
63
     * @return AddressEmbeddable
64
     */
65 2
    private function setHouseNumber(string $houseNumber): AddressEmbeddableInterface
66
    {
67 2
        $this->notifyEmbeddablePrefixedProperties(
68 2
            'houseNumber',
69 2
            $this->houseNumber,
70 2
            $houseNumber
71
        );
72 2
        $this->houseNumber = $houseNumber;
73
74 2
        return $this;
75
    }
76
77
    /**
78
     * @param string $houseName
79
     *
80
     * @return AddressEmbeddable
81
     */
82 2
    private function setHouseName(string $houseName): AddressEmbeddableInterface
83
    {
84 2
        $this->notifyEmbeddablePrefixedProperties(
85 2
            'houseName',
86 2
            $this->houseName,
87 2
            $houseName
88
        );
89 2
        $this->houseName = $houseName;
90
91 2
        return $this;
92
    }
93
94
    /**
95
     * @param string $street
96
     *
97
     * @return AddressEmbeddable
98
     */
99 2
    private function setStreet(string $street): AddressEmbeddableInterface
100
    {
101 2
        $this->notifyEmbeddablePrefixedProperties(
102 2
            'street',
103 2
            $this->street,
104 2
            $street
105
        );
106 2
        $this->street = $street;
107
108 2
        return $this;
109
    }
110
111
    /**
112
     * @param string $city
113
     *
114
     * @return AddressEmbeddable
115
     */
116 2
    private function setCity(string $city): AddressEmbeddableInterface
117
    {
118 2
        $this->notifyEmbeddablePrefixedProperties(
119 2
            'city',
120 2
            $this->city,
121 2
            $city
122
        );
123 2
        $this->city = $city;
124
125 2
        return $this;
126
    }
127
128
    /**
129
     * @param string $countryCode
130
     *
131
     * @return AddressEmbeddable
132
     */
133 2
    private function setCountryCode(string $countryCode): AddressEmbeddableInterface
134
    {
135 2
        $this->notifyEmbeddablePrefixedProperties(
136 2
            'countryCode',
137 2
            $this->countryCode,
138 2
            $countryCode
139
        );
140 2
        $this->countryCode = $countryCode;
141
142 2
        return $this;
143
    }
144
145
    /**
146
     * @param string $postalCode
147
     *
148
     * @return AddressEmbeddable
149
     */
150 2
    private function setPostalCode(string $postalCode): AddressEmbeddableInterface
151
    {
152 2
        $this->notifyEmbeddablePrefixedProperties(
153 2
            'postalCode',
154 2
            $this->postalCode,
155 2
            $postalCode
156
        );
157 2
        $this->postalCode = $postalCode;
158
159 2
        return $this;
160
    }
161
162
    /**
163
     * @param string $postalArea
164
     *
165
     * @return AddressEmbeddable
166
     */
167 2
    private function setPostalArea(string $postalArea): AddressEmbeddableInterface
168
    {
169 2
        $this->notifyEmbeddablePrefixedProperties(
170 2
            'postalArea',
171 2
            $this->postalArea,
172 2
            $postalArea
173
        );
174 2
        $this->postalArea = $postalArea;
175
176 2
        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 2
    public static function create(array $properties): AddressEmbeddableInterface
206
    {
207 2
        if (array_key_exists(AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER, $properties)) {
208 2
            return new self(
209 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER],
210 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NAME],
211 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_STREET],
212 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_CITY],
213 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_AREA],
214 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_CODE],
215 2
                $properties[AddressEmbeddableInterface::EMBEDDED_PROP_COUNTRY_CODE]
216
            );
217
        }
218
219
        return new self(...array_values($properties));
220
    }
221
222
    public function __toString(): string
223
    {
224
        return (string)print_r(
225
            [
226
                'addressEmbeddable' => [
227
                    AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NUMBER => $this->getHouseNumber(),
228
                    AddressEmbeddableInterface::EMBEDDED_PROP_HOUSE_NAME   => $this->getHouseName(),
229
                    AddressEmbeddableInterface::EMBEDDED_PROP_STREET       => $this->getStreet(),
230
                    AddressEmbeddableInterface::EMBEDDED_PROP_CITY         => $this->getCity(),
231
                    AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_AREA  => $this->getPostalArea(),
232
                    AddressEmbeddableInterface::EMBEDDED_PROP_POSTAL_CODE  => $this->getPostalCode(),
233
                    AddressEmbeddableInterface::EMBEDDED_PROP_COUNTRY_CODE => $this->getCountryCode(),
234
                ],
235
            ],
236
            true
237
        );
238
    }
239
240
    /**
241
     * @return string
242
     */
243 2
    public function getHouseNumber(): string
244
    {
245 2
        return $this->houseNumber ?? '';
246
    }
247
248
    /**
249
     * @return string
250
     */
251 2
    public function getHouseName(): string
252
    {
253 2
        return $this->houseName ?? '';
254
    }
255
256
    /**
257
     * @return string
258
     */
259 2
    public function getStreet(): string
260
    {
261 2
        return $this->street ?? '';
262
    }
263
264
    /**
265
     * @return string
266
     */
267 2
    public function getCity(): string
268
    {
269 2
        return $this->city ?? '';
270
    }
271
272
    /**
273
     * @return string
274
     */
275 2
    public function getPostalCode(): string
276
    {
277 2
        return $this->postalCode ?? '';
278
    }
279
280
    /**
281
     * @return string
282
     */
283 2
    public function getPostalArea(): string
284
    {
285 2
        return $this->postalArea ?? '';
286
    }
287
288
    /**
289
     * @return string
290
     */
291 2
    public function getCountryCode(): string
292
    {
293 2
        return $this->countryCode ?? '';
294
    }
295
296
    protected function getPrefix(): string
297
    {
298
        return HasAddressEmbeddableInterface::PROP_ADDRESS_EMBEDDABLE;
299
    }
300
}
301