ParcelShopSearchRequest::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 13
rs 9.9332
cc 1
nc 1
nop 0
1
<?php
2
3
namespace DPD\Interconnector\Request;
4
5
use DPD\Interconnector\Authentication;
6
7
class ParcelShopSearchRequest extends Request
8
{
9
    private $fetchGsPUDOpoint;
10
    private $countryCode;
11
    private $postCode;
12
    private $street;
13
    private $city;
14
    private $id;
15
    private $company;
16
    private $retrieveOpeningHours;
17
18
    public function __construct(
19
        Authentication $authentication,
20
        bool $fetchGsPUDOpoint, 
21
        string $countryCode, 
22
        ?string $postCode = null, 
23
        ?string $street = null,
24
        ?string $city = null,
25
        ?string $id = null,
26
        ?string $company = null,
27
        bool $retrieveOpeningHours = false
28
    ) {
29
        parent::__construct($authentication);
30
31
        $this->fetchGsPUDOpoint = $fetchGsPUDOpoint;
32
        $this->countryCode = $countryCode;
33
        $this->postCode = $postCode;
34
        $this->street = $street;
35
        $this->city = $city;
36
        $this->id = $id;
37
        $this->company = $company;
38
        $this->retrieveOpeningHours = $retrieveOpeningHours;
39
    }
40
41
    public function toArray(): array
42
    {
43
        return array_merge(
44
            $this->authentication->toArray(),
45
            [
46
                'id' => $this->id,
47
                'company' => $this->company,
48
                'street' => $this->street,
49
                'city' => $this->city,
50
                'country' => $this->countryCode,
51
                'pcode' => $this->postCode,
52
                'fetchGsPUDOpoint' => (int)$this->fetchGsPUDOpoint,
53
                'retrieveOpeningHours' => (int)$this->retrieveOpeningHours
54
            ]
55
        );
56
    }
57
}