Passed
Pull Request — 1.x (#36)
by Darío
03:55 queued 01:55
created

Subscriber   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Test Coverage

Coverage 31.58%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 16
eloc 33
c 2
b 0
f 0
dl 0
loc 93
ccs 12
cts 38
cp 0.3158
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A setEmailAddress() 0 5 1
A setPhone() 0 5 1
A getEmailAddress() 0 3 1
A getPayerId() 0 3 1
A setName() 0 5 1
A setPayerId() 0 5 1
A setShippingAddress() 0 5 1
A toArray() 0 25 6
A getShippingAddress() 0 3 1
A getPhone() 0 3 1
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