Passed
Push — 2.x ( 38b938...a8319a )
by Darío
04:56 queued 02:35
created

UpdatePlanRequest::getPlanId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Plans\Requests;
4
5
use PaymentGateway\PayPalSdk\Plans\Concerns\HasPlanDescription;
6
use PaymentGateway\PayPalSdk\Subscriptions\Concerns\HasPaymentPreferences;
7
8
class UpdatePlanRequest
9
{
10
    use HasPlanDescription;
11
    use HasPaymentPreferences;
12
13
    protected string $planId;
14
15 5
    public function __construct(string $planId)
16
    {
17 5
        $this->planId = $planId;
18 5
    }
19
20 3
    public function getPlanId(): string
21
    {
22 3
        return $this->planId;
23
    }
24
25 1
    public function setPlanId(string $planId): self
26
    {
27 1
        $this->planId = $planId;
28
29 1
        return $this;
30
    }
31
32 5
    public function toArray(): array
33
    {
34 5
        $request = [];
35
36 5
        if ($this->planDescription ?? null) {
37 2
            $request[] = [
38 2
                'op' => 'replace',
39 2
                'path' => '/description',
40 2
                'value' => $this->planDescription
41
            ];
42
        }
43
44 5
        if ($this->paymentPreferences ?? null) {
45 4
            $request[] = [
46 4
                'op' => 'replace',
47 4
                'path' => '/payment_preferences/auto_bill_outstanding',
48 4
                'value' => $this->paymentPreferences->isAutoBillOutstanding()
49
            ];
50 4
            $request[] = [
51 4
                'op' => 'replace',
52 4
                'path' => '/payment_preferences/payment_failure_threshold',
53 4
                'value' => $this->paymentPreferences->getPaymentFailureThreshold()
54
            ];
55 4
            $request[] = [
56 4
                'op' => 'replace',
57 4
                'path' => '/payment_preferences/setup_fee_failure_action',
58 4
                'value' => $this->paymentPreferences->getSetupFeeFailureAction()
59
            ];
60
61 4
            if ($this->paymentPreferences->getSetupFee()) {
62 3
                $request[] = [
63 3
                    'op' => 'replace',
64 3
                    'path' => '/payment_preferences/setup_fee',
65 3
                    'value' => $this->paymentPreferences->getSetupFee()->toArray()
66
                ];
67
            }
68
        }
69
70 5
        return $request;
71
    }
72
}
73