Passed
Pull Request — 1.x (#36)
by Darío
09:41 queued 06:52
created

Subscriber   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 31.58%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 16
eloc 28
c 1
b 0
f 0
dl 0
loc 83
ccs 12
cts 38
cp 0.3158
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setEmailAddress() 0 3 1
A setPhone() 0 3 1
A getEmailAddress() 0 3 1
A getPayerId() 0 3 1
A setName() 0 3 1
A setPayerId() 0 3 1
A setShippingAddress() 0 3 1
A toArray() 0 25 6
A getShippingAddress() 0 3 1
A getName() 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): void
19
    {
20 2
        $this->name = $name;
21 2
    }
22
23
    public function getEmailAddress(): ?string
24
    {
25
        return $this->emailAddress;
26
    }
27
28
    public function setEmailAddress(?string $emailAddress): void
29
    {
30
        $this->emailAddress = $emailAddress;
31
    }
32
33
    public function getPayerId(): ?string
34
    {
35
        return $this->payerId;
36
    }
37
38
    public function setPayerId(?string $payerId): void
39
    {
40
        $this->payerId = $payerId;
41
    }
42
43
    public function getPhone(): ?Phone
44
    {
45
        return $this->phone;
46
    }
47
48
    public function setPhone(?Phone $phone): void
49
    {
50
        $this->phone = $phone;
51
    }
52
53
    public function getShippingAddress(): ?ShippingAddress
54
    {
55
        return $this->shippingAddress;
56
    }
57
58
    public function setShippingAddress(?ShippingAddress $shippingAddress): void
59
    {
60
        $this->shippingAddress = $shippingAddress;
61
    }
62
63 2
    public function toArray(): array
64
    {
65 2
        $data = [];
66
67 2
        if ($this->name) {
68 2
            $data['name'] = $this->name->toArray();
69
        }
70
71 2
        if ($this->emailAddress) {
72
            $data['email_address'] = $this->emailAddress;
73
        }
74
75 2
        if ($this->payerId) {
76
            $data['payer_id'] = $this->payerId;
77
        }
78
79 2
        if ($this->phone) {
80
            $data['phone'] = $this->phone->toArray();
81
        }
82
83 2
        if ($this->shippingAddress) {
84
            $data['shipping_address'] = $this->shippingAddress->toArray();
85
        }
86
87 2
        return $data;
88
    }
89
}
90