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.

Address   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A create() 0 4 1
A fromResponse() 0 11 1
A toArray() 0 11 1
1
<?php
2
3
namespace Spatie\BpostAddressWebservice;
4
5
class Address
6
{
7
    /** @var string */
8
    public $streetName;
9
10
    /** @var string */
11
    public $streetNumber;
12
13
    /** @var string */
14
    public $boxNumber;
15
16
    /** @var string */
17
    public $postalCode;
18
19
    /** @var string */
20
    public $municipalityName;
21
22
    /** @var string */
23
    public $country = 'BELGIE';
24
25
    protected function __construct(array $attributes)
26
    {
27
        foreach ($attributes as $attribute => $value) {
28
            if (property_exists($this, $attribute)) {
29
                $this->$attribute = $value;
30
            }
31
        }
32
    }
33
34
    public static function create(array $attributes): Address
35
    {
36
        return new static($attributes);
37
    }
38
39
    public static function fromResponse(array $attributes): Address
40
    {
41
        return new static([
42
            'streetName' => $attributes['PostalAddress']['StructuredDeliveryPointLocation']['StreetName'] ?? '',
43
            'streetNumber' => $attributes['PostalAddress']['StructuredDeliveryPointLocation']['StreetNumber'] ?? '',
44
            'boxNumber' => $attributes['PostalAddress']['StructuredDeliveryPointLocation']['BoxNumber'] ?? '',
45
            'postalCode' => $attributes['PostalAddress']['StructuredPostalCodeMunicipality']['PostalCode'] ?? '',
46
            'municipalityName' => $attributes['PostalAddress']['StructuredPostalCodeMunicipality']['MunicipalityName'] ?? '',
47
            'country' => $attributes['PostalAddress']['CountryName'] ?? '',
48
        ]);
49
    }
50
51
    public function toArray(): array
52
    {
53
        return [
54
            'streetName' => $this->streetName,
55
            'streetNumber' => $this->streetNumber,
56
            'boxNumber' => $this->boxNumber,
57
            'postalCode' => $this->postalCode,
58
            'municipalityName' => $this->municipalityName,
59
            'country' => $this->country,
60
        ];
61
    }
62
}
63