Address::Customer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Lifeboat\Models;
4
5
use Lifeboat\Exceptions\ApiException;
6
use Lifeboat\Exceptions\OAuthException;
7
use Lifeboat\Services\Addresses;
8
9
/**
10
 * Class Address
11
 * @package Lifeboat\Models
12
 *
13
 * @property string $Name
14
 * @property string $Address
15
 * @property string $AddressL2
16
 * @property string $City
17
 * @property string $SubdivisionCode
18
 * @property string $CountryCode
19
 * @property string $PostCode
20
 * @property string|null $Notes
21
 * @property string|null $Latitude
22
 * @property string|null $Longitude
23
 * @property string $Email
24
 * @property string|null $Tel
25
 * @property string|null $VATNo
26
 * @property bool $isDefault
27
 * @property string $Country
28
 * @property string $Subdivision
29
 * @property int $CustomerID
30
 */
31
class Address extends Model {
32
33
    protected static $casting = [
34
        'isDefault'     => 'boolval',
35
        'CustomerID'    => 'intval'
36
    ];
37
38
    /**
39
     * @return Customer|null
40
     * @throws ApiException
41
     * @throws OAuthException
42
     */
43
    public function Customer(): ?Customer
44
    {
45
        if (!$this->CustomerID) return null;
46
47
        /** @var Customer|null $customer */
48
        $customer = $this->getClient()->customers->fetch($this->CustomerID);
49
50
        return $customer;
51
    }
52
}
53