Completed
Branch develop (8166a6)
by Romain
01:52
created

Address   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A setAdditionalStreet() 0 6 1
A jsonSerialize() 0 13 1
1
<?php
2
namespace Kerox\Messenger\Model\Message\Attachment\Template\Receipt;
3
4
class Address implements \JsonSerializable
5
{
6
7
    /**
8
     * @var string
9
     */
10
    protected $street;
11
12
    /**
13
     * @var null|string
14
     */
15
    protected $additionalStreet;
16
17
    /**
18
     * @var string
19
     */
20
    protected $city;
21
22
    /**
23
     * @var string
24
     */
25
    protected $postalCode;
26
27
    /**
28
     * @var string
29
     */
30
    protected $state;
31
32
    /**
33
     * @var string
34
     */
35
    protected $country;
36
37
    /**
38
     * Address constructor.
39
     *
40
     * @param string $street
41
     * @param string $city
42
     * @param string $postalCode
43
     * @param string $state
44
     * @param string $country
45
     */
46
    public function __construct(string $street,
47
                                string $city,
48
                                string $postalCode,
49
                                string $state,
50
                                string $country
51
    ) {
52
        $this->street = $street;
53
        $this->city = $city;
54
        $this->postalCode = $postalCode;
55
        $this->state = $state;
56
        $this->country = $country;
57
    }
58
59
    /**
60
     * @param string $additionalStreet
61
     * @return Address
62
     */
63
    public function setAdditionalStreet(string $additionalStreet): Address
64
    {
65
        $this->additionalStreet = $additionalStreet;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function jsonSerialize(): array
74
    {
75
        $json = [
76
            'street_1' => $this->street,
77
            'street_2' => $this->additionalStreet,
78
            'city' => $this->city,
79
            'postal_code' => $this->postalCode,
80
            'state' => $this->state,
81
            'country' => $this->country,
82
        ];
83
84
        return array_filter($json);
85
    }
86
}
87