Passed
Push — feature/refactor-subscription-... ( 326c18 )
by Darío
03:04
created

PayerName::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

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