Completed
Push — master ( c9eeb2...84d5f3 )
by Baldur
03:47 queued 01:58
created

Address::toArray()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 26
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 8.439
c 0
b 0
f 0
cc 6
eloc 13
nc 32
nop 1
crap 6
1
<?php
2
3
namespace LAShowroom\TaxJarBundle\Model;
4
5
class Address
6
{
7
    /**
8
     * @var string
9
     */
10
    private $street;
11
12
    /**
13
     * @var string
14
     */
15
    private $city;
16
17
    /**
18
     * @var string
19
     */
20
    private $state;
21
22
    /**
23
     * @var string
24
     */
25
    private $zip;
26
27
    /**
28
     * @var string
29
     */
30
    private $country;
31
32
    /**
33
     * @param string $street
34
     * @param string $city
35
     * @param string $state
36
     * @param string $zip
37
     * @param string $country
38
     */
39 18
    public function __construct($street, $city, $state, $zip, $country)
40
    {
41 18
        $this->street = $street;
42 18
        $this->city = $city;
43 18
        $this->state = $state;
44 18
        $this->zip = $zip;
45 18
        $this->country = $country;
46 18
    }
47
48
    /**
49
     * @return string
50
     */
51 14
    public function getStreet()
52
    {
53 14
        return $this->street;
54
    }
55
56
    /**
57
     * @return string
58
     */
59 14
    public function getCity()
60
    {
61 14
        return $this->city;
62
    }
63
64
    /**
65
     * @return string
66
     */
67 14
    public function getState()
68
    {
69 14
        return $this->state;
70
    }
71
72
    /**
73
     * @return string
74
     */
75 14
    public function getZip()
76
    {
77 14
        return $this->zip;
78
    }
79
80
    /**
81
     * @return string
82
     */
83 14
    public function getCountry()
84
    {
85 14
        return $this->country;
86
    }
87
88 14
    public function toArray($prefix = '')
89
    {
90 14
        $result = [];
91
92 14
        if (!empty($this->getStreet())) {
93 14
            $result[sprintf('%sstreet', $prefix)] = $this->getStreet();
94
        }
95
96 14
        if (!empty($this->getCity())) {
97 14
            $result[sprintf('%scity', $prefix)] = $this->getCity();
98
        }
99
100 14
        if (!empty($this->getState())) {
101 14
            $result[sprintf('%sstate', $prefix)] = $this->getState();
102
        }
103
104 14
        if (!empty($this->getZip())) {
105 14
            $result[sprintf('%szip', $prefix)] = $this->getZip();
106
        }
107
108 14
        if (!empty($this->getCountry())) {
109 14
            $result[sprintf('%scountry', $prefix)] = $this->getCountry();
110
        }
111
112 14
        return $result;
113
    }
114
}
115