CorrectedAddressTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
getData() 0 1 ?
A getCorrectedAddress() 0 14 2
A hasCorrectedAddress() 0 4 1
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