Passed
Pull Request — 1.x (#36)
by Darío
04:17 queued 02:03
created

Subscriber::setShippingAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Subscriptions;
4
5
class Subscriber
6
{
7
    private ?PayerName $name = null;
8
    private ?string $emailAddress = null;
9
    private ?string $payerId = null;
10
    private ?Phone $phone = null;
11
    private ?ShippingAddress $shippingAddress = null;
12
13
    public function getName(): ?PayerName
14
    {
15
        return $this->name;
16
    }
17
18 2
    public function setName(?PayerName $name): self
19
    {
20 2
        $this->name = $name;
21
22 2
        return $this;
23
    }
24
25
    public function getEmailAddress(): ?string
26
    {
27
        return $this->emailAddress;
28
    }
29
30
    public function setEmailAddress(?string $emailAddress): self
31
    {
32
        $this->emailAddress = $emailAddress;
33
34
        return $this;
35
    }
36
37
    public function getPayerId(): ?string
38
    {
39
        return $this->payerId;
40
    }
41
42
    public function setPayerId(?string $payerId): self
43
    {
44
        $this->payerId = $payerId;
45
46
        return $this;
47
    }
48
49
    public function getPhone(): ?Phone
50
    {
51
        return $this->phone;
52
    }
53
54
    public function setPhone(?Phone $phone): self
55
    {
56
        $this->phone = $phone;
57
58
        return $this;
59
    }
60
61
    public function getShippingAddress(): ?ShippingAddress
62
    {
63
        return $this->shippingAddress;
64
    }
65
66
    public function setShippingAddress(?ShippingAddress $shippingAddress): self
67
    {
68
        $this->shippingAddress = $shippingAddress;
69
70
        return $this;
71
    }
72
73 2
    public function toArray(): array
74
    {
75 2
        $data = [];
76
77 2
        if ($this->name) {
78 2
            $data['name'] = $this->name->toArray();
79
        }
80
81 2
        if ($this->emailAddress) {
82
            $data['email_address'] = $this->emailAddress;
83
        }
84
85 2
        if ($this->payerId) {
86
            $data['payer_id'] = $this->payerId;
87
        }
88
89 2
        if ($this->phone) {
90
            $data['phone'] = $this->phone->toArray();
91
        }
92
93 2
        if ($this->shippingAddress) {
94
            $data['shipping_address'] = $this->shippingAddress->toArray();
95
        }
96
97 2
        return $data;
98
    }
99
}
100