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.

ValidateAddressesRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A addresses() 0 4 1
A getBody() 0 33 1
1
<?php
2
3
namespace Spatie\BpostAddressWebservice\Requests;
4
5
use Spatie\BpostAddressWebservice\Address;
6
7
class ValidateAddressesRequest
8
{
9
    /** @var array */
10
    protected $addresses;
11
12
    /** @var array */
13
    protected $options;
14
15
    public function __construct(array $addresses, array $options)
16
    {
17
        $this->addresses = $addresses;
18
19
        $this->options = $options;
20
    }
21
22
    public function addresses(): array
23
    {
24
        return $this->addresses;
25
    }
26
27
    public function getBody(): array
28
    {
29
        $addresses = array_map(function (Address $address, int $i) {
30
            return [
31
                '@id' => $i,
32
                'PostalAddress' => [
33
                    'DeliveryPointLocation' => [
34
                        'StructuredDeliveryPointLocation' => [
35
                            'StreetName' => $address->streetName,
36
                            'StreetNumber' => $address->streetNumber,
37
                            'BoxNumber' => $address->boxNumber,
38
                        ],
39
                    ],
40
                    'PostalCodeMunicipality' => [
41
                        'StructuredPostalCodeMunicipality' => [
42
                            'PostalCode' => $address->postalCode,
43
                            'MunicipalityName' => $address->municipalityName,
44
                        ],
45
                    ],
46
                ],
47
                'DeliveringCountryISOCode' => $address->country,
48
            ];
49
        }, $this->addresses, array_keys(array_values($this->addresses)));
50
51
        return [
52
            'ValidateAddressesRequest' => [
53
                'AddressToValidateList' => [
54
                    'AddressToValidate' => $addresses,
55
                ],
56
                'ValidateAddressOptions' => $this->options,
57
            ],
58
        ];
59
    }
60
}
61