CorrectedAddressTrait::getCorrectedAddress()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 14
ccs 9
cts 9
cp 1
crap 2
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Omnipay\BillPay\Message\ResponseData;
4
5
use SimpleXMLElement;
6
7
/**
8
 * Access corrected address in the response, internal usage only
9
 *
10
 * @author    Andreas Lange <[email protected]>
11
 * @copyright 2016, Connox GmbH
12
 * @license   MIT
13
 */
14
trait CorrectedAddressTrait
15
{
16
    /**
17
     * Gets the corrected address
18
     *
19
     * @return array|null
20
     */
21 3
    public function getCorrectedAddress()
22
    {
23 3
        if (!$this->hasCorrectedAddress()) {
24 2
            return null;
25
        }
26
27
        return [
28 1
            'street' => (string)$this->getData()->corrected_address['street'],
29 1
            'streetNo' => (string)$this->getData()->corrected_address['streetNo'],
30 1
            'zip' => (string)$this->getData()->corrected_address['zip'],
31 1
            'city' => (string)$this->getData()->corrected_address['city'],
32 1
            'country' => (string)$this->getData()->corrected_address['country'],
33 1
        ];
34
    }
35
36
    /**
37
     * @return SimpleXMLElement
38
     *
39
     * @codeCoverageIgnore
40
     */
41
    abstract public function getData();
42
43
    /**
44
     * @return bool
45
     */
46 3
    public function hasCorrectedAddress()
47
    {
48 3
        return isset($this->getData()->corrected_address);
49
    }
50
}
51