Address::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 7
dl 0
loc 21
ccs 11
cts 11
cp 1
crap 2
rs 9.584
c 0
b 0
f 0
1
<?php
2
namespace PHPSC\PagSeguro\Customer;
3
4
use JMS\Serializer\Annotation as Serializer;
5
use PHPSC\PagSeguro\SerializerTrait;
6
7
/**
8
 * @Serializer\AccessType("public_method")
9
 * @Serializer\ReadOnly
10
 * @Serializer\XmlRoot("address")
11
 *
12
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
13
 */
14
class Address
15
{
16
    use SerializerTrait;
17
18
    /**
19
     * @var string
20
     */
21
    private $country;
22
23
    /**
24
     * @var string
25
     */
26
    private $state;
27
28
    /**
29
     * @var string
30
     */
31
    private $city;
32
33
    /**
34
     * @var string
35
     */
36
    private $postalCode;
37
38
    /**
39
     * @var string
40
     */
41
    private $district;
42
43
    /**
44
     * @var string
45
     */
46
    private $street;
47
48
    /**
49
     * @var string
50
     */
51
    private $number;
52
53
    /**
54
     * @var string
55
     */
56
    private $complement;
57
58
    /**
59
     * @param string $state
60
     * @param string $city
61
     * @param string $postalCode
62
     * @param string $district
63
     * @param string $street
64
     * @param string $number
65
     * @param string $complement
66
     */
67 23
    public function __construct(
68
        $state,
69
        $city,
70
        $postalCode,
71
        $district,
72
        $street,
73
        $number,
74
        $complement = null
75
    ) {
76 23
        $this->country    = 'BRA';
77 23
        $this->state      = (string) $state;
78 23
        $this->city       = (string) $city;
79 23
        $this->postalCode = preg_replace('/[^0-9]/', '', (string) $postalCode);
80 23
        $this->district   = (string) $district;
81 23
        $this->street     = (string) $street;
82 23
        $this->number     = (string) $number;
83
84 23
        if (!empty($complement)) {
85 21
            $this->complement = (string) $complement;
86
        }
87 23
    }
88
89
    /**
90
     * @return string
91
     */
92 8
    public function getCountry()
93
    {
94 8
        return $this->country;
95
    }
96
97
    /**
98
     * @return string
99
     */
100 8
    public function getState()
101
    {
102 8
        return $this->state;
103
    }
104
105
    /**
106
     * @return string
107
     */
108 8
    public function getCity()
109
    {
110 8
        return $this->city;
111
    }
112
113
    /**
114
     * @return string
115
     */
116 8
    public function getPostalCode()
117
    {
118 8
        return $this->postalCode;
119
    }
120
121
    /**
122
     * @return string
123
     */
124 8
    public function getDistrict()
125
    {
126 8
        return $this->district;
127
    }
128
129
    /**
130
     * @return string
131
     */
132 8
    public function getStreet()
133
    {
134 8
        return $this->street;
135
    }
136
137
    /**
138
     * @return string
139
     */
140 8
    public function getNumber()
141
    {
142 8
        return $this->number;
143
    }
144
145
    /**
146
     * @return string
147
     */
148 8
    public function getComplement()
149
    {
150 8
        return $this->complement;
151
    }
152
}
153