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

Phone::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Subscriptions;
4
5
class Phone
6
{
7
    private string $phoneNumber;
8
    private ?string $phoneType = null;
9
10
    public function __construct(string $phoneNumber)
11
    {
12
        $this->phoneNumber = $phoneNumber;
13
    }
14
15
    public function getPhoneNumber(): string
16
    {
17
        return $this->phoneNumber;
18
    }
19
20
    public function setPhoneNumber(string $phoneNumber): self
21
    {
22
        $this->phoneNumber = $phoneNumber;
23
24
        return $this;
25
    }
26
27
    public function getPhoneType(): ?string
28
    {
29
        return $this->phoneType;
30
    }
31
32
    public function setPhoneType(?string $phoneType): self
33
    {
34
        $this->phoneType = $phoneType;
35
36
        return $this;
37
    }
38
39
    public function toArray(): array
40
    {
41
        $data = [
42
            'phone_number' => $this->phoneNumber,
43
        ];
44
45
        if ($this->phoneType) {
46
            $data['phone_type'] = $this->phoneType;
47
        }
48
49
        return $data;
50
    }
51
}
52