BaseAddress   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 30.23%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 0
dl 0
loc 154
ccs 13
cts 43
cp 0.3023
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getCareOf() 0 4 1
A withCareOf() 0 7 1
A getStreetAddress() 0 4 1
A withStreetAddress() 0 7 1
A getZipCode() 0 4 1
A withZipCode() 0 7 1
A getCity() 0 4 1
A withCity() 0 7 1
A getCountry() 0 4 1
A withCountry() 0 7 1
B toArray() 0 21 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model;
6
7
/**
8
 * @author Ibrahim Hizeoui <[email protected]>
9
 */
10
abstract class BaseAddress implements CreatableFromArray
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $streetAddress;
16
17
    /**
18
     * @var string
19
     */
20
    protected $careOf;
21
22
    /**
23
     * @var string
24
     */
25
    protected $zipCode;
26
27
    /**
28
     * @var string
29
     */
30
    protected $city;
31
32
    /**
33
     * @var string
34
     */
35
    protected $country;
36
37
    /**
38
     * @return string
39
     */
40
    public function getCareOf()
41
    {
42
        return $this->careOf;
43
    }
44
45
    /**
46
     * @param string $careOf
47
     *
48
     * @return self
49
     */
50
    public function withCareOf(string $careOf)
51
    {
52
        $new = clone $this;
53
        $new->careOf = $careOf;
54
55
        return $new;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getStreetAddress()
62
    {
63
        return $this->streetAddress;
64
    }
65
66
    /**
67
     * @param string $streetAddress
68
     *
69
     * @return self
70
     */
71
    public function withStreetAddress(string $streetAddress)
72
    {
73
        $new = clone $this;
74
        $new->streetAddress = $streetAddress;
75
76
        return $new;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getZipCode()
83
    {
84
        return $this->zipCode;
85
    }
86
87
    /**
88
     * @param string $zipCode
89
     *
90
     * @return self
91
     */
92
    public function withZipCode(string $zipCode)
93
    {
94
        $new = clone $this;
95
        $new->zipCode = $zipCode;
96
97
        return $new;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getCity()
104
    {
105
        return $this->city;
106
    }
107
108
    /**
109
     * @param string $city
110
     *
111
     * @return self
112
     */
113
    public function withCity(string $city)
114
    {
115
        $new = clone $this;
116
        $new->city = $city;
117
118
        return $new;
119
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getCountry()
125
    {
126
        return $this->country;
127
    }
128
129
    /**
130
     * @param string $country
131
     *
132
     * @return self
133
     */
134
    public function withCountry(string $country)
135
    {
136
        $new = clone $this;
137
        $new->country = $country;
138
139
        return $new;
140
    }
141
142 1
    public function toArray()
143
    {
144 1
        $data = [];
145 1
        if (null !== $this->streetAddress) {
146 1
            $data['street_address'] = $this->streetAddress;
147
        }
148 1
        if (null !== $this->careOf) {
149 1
            $data['careof'] = $this->careOf;
150
        }
151 1
        if (null !== $this->zipCode) {
152 1
            $data['zipcode'] = $this->zipCode;
153
        }
154 1
        if (null !== $this->city) {
155 1
            $data['city'] = $this->city;
156
        }
157 1
        if (null !== $this->country) {
158 1
            $data['country'] = $this->country;
159
        }
160
161 1
        return $data;
162
    }
163
}
164