Passed
Push — 1.x ( 0b54d1...86e2e1 )
by Darío
44s queued 11s
created

PaymentPreferences   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 68.97%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 11
eloc 20
c 1
b 0
f 1
dl 0
loc 64
ccs 20
cts 29
cp 0.6897
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 7 1
A setAutoBillOutstanding() 0 3 1
A setSetupFeeFailureAction() 0 3 1
A setSetupFee() 0 3 1
A isAutoBillOutstanding() 0 3 1
A __construct() 0 4 2
A getSetupFee() 0 3 1
A setPaymentFailureThreshold() 0 3 1
A getSetupFeeFailureAction() 0 3 1
A getPaymentFailureThreshold() 0 3 1
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Subscriptions;
4
5
use PaymentGateway\PayPalSdk\Subscriptions\Constants\InitialPaymentFailureAction;
6
7
class PaymentPreferences
8
{
9
    protected Money $setupFee;
10
11
    protected bool $autoBillOutstanding = true;
12
13
    protected int $paymentFailureThreshold = 0;
14
15
    protected string $setupFeeFailureAction = InitialPaymentFailureAction::CANCEL;
16
17 4
    public function __construct(?Money $setupFee = null)
18
    {
19 4
        if ($setupFee) {
20 4
            $this->setSetupFee($setupFee);
21
        }
22 4
    }
23
24 1
    public function getSetupFee(): Money
25
    {
26 1
        return $this->setupFee;
27
    }
28
29 4
    public function setSetupFee(Money $setupFee): void
30
    {
31 4
        $this->setupFee = $setupFee;
32 4
    }
33
34 1
    public function isAutoBillOutstanding(): bool
35
    {
36 1
        return $this->autoBillOutstanding;
37
    }
38
39
    public function setAutoBillOutstanding(bool $autoBillOutstanding): void
40
    {
41
        $this->autoBillOutstanding = $autoBillOutstanding;
42
    }
43
44 1
    public function getPaymentFailureThreshold(): int
45
    {
46 1
        return $this->paymentFailureThreshold;
47
    }
48
49
    public function setPaymentFailureThreshold(int $paymentFailureThreshold): void
50
    {
51
        $this->paymentFailureThreshold = $paymentFailureThreshold;
52
    }
53
54 1
    public function getSetupFeeFailureAction(): string
55
    {
56 1
        return $this->setupFeeFailureAction;
57
    }
58
59
    public function setSetupFeeFailureAction(string $setupFeeFailureAction): void
60
    {
61
        $this->setupFeeFailureAction = $setupFeeFailureAction;
62
    }
63
64 4
    public function toArray(): array
65
    {
66
        return [
67 4
            'auto_bill_outstanding' => $this->autoBillOutstanding,
68 4
            'setup_fee' => $this->setupFee->toArray(),
69 4
            'setup_fee_failure_action' => $this->setupFeeFailureAction,
70 4
            'payment_failure_threshold' => $this->paymentFailureThreshold
71
        ];
72
    }
73
}
74