Passed
Push — master ( 745713...423bfb )
by Darío
07:06 queued 04:58
created

UpdatePlanRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
wmc 5
eloc 30
dl 0
loc 53
ccs 26
cts 30
cp 0.8667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 36 3
A __construct() 0 3 1
A getId() 0 3 1
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Subscriptions\Requests;
4
5
use PaymentGateway\PayPalSdk\Products\Concerns\HasDescription;
6
use PaymentGateway\PayPalSdk\Subscriptions\Concerns\HasPaymentPreferences;
7
8
class UpdatePlanRequest
9
{
10
    use HasDescription;
11
    use HasPaymentPreferences;
12
13
    protected string $id;
14
15 1
    public function __construct(string $id)
16
    {
17 1
        $this->id = $id;
18 1
    }
19
20 1
    public function getId(): string
21
    {
22 1
        return $this->id;
23
    }
24
25 1
    public function toArray(): array
26
    {
27 1
        $request = [];
28
29 1
        if ($this->description ?? null) {
30
            $request[] = [
31
                'op' => 'replace',
32
                'path' => '/description',
33
                'value' => $this->description
34
            ];
35
        }
36
37 1
        if ($this->paymentPreferences ?? null) {
38 1
            $request[] = [
39 1
                'op' => 'replace',
40 1
                'path' => '/payment_preferences/auto_bill_outstanding',
41 1
                'value' => $this->paymentPreferences->isAutoBillOutstanding()
42
            ];
43 1
            $request[] = [
44 1
                'op' => 'replace',
45 1
                'path' => '/payment_preferences/payment_failure_threshold',
46 1
                'value' => $this->paymentPreferences->getPaymentFailureThreshold()
47
            ];
48 1
            $request[] = [
49 1
                'op' => 'replace',
50 1
                'path' => '/payment_preferences/setup_fee_failure_action',
51 1
                'value' => $this->paymentPreferences->getSetupFeeFailureAction()
52
            ];
53 1
            $request[] = [
54 1
                'op' => 'replace',
55 1
                'path' => '/payment_preferences/setup_fee',
56 1
                'value' => $this->paymentPreferences->getSetupFee()->toArray()
57
            ];
58
        }
59
60 1
        return $request;
61
    }
62
}
63