Passed
Push — master ( 9dc2b5...745713 )
by Darío
03:33 queued 01:28
created

PaymentPreferences   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 62
ccs 16
cts 28
cp 0.5714
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
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 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)
18
    {
19 4
        $this->setupFee = $setupFee;
20 4
    }
21
22 1
    public function getSetupFee(): Money
23
    {
24 1
        return $this->setupFee;
25
    }
26
27
    public function setSetupFee(Money $setupFee): void
28
    {
29
        $this->setupFee = $setupFee;
30
    }
31
32 1
    public function isAutoBillOutstanding(): bool
33
    {
34 1
        return $this->autoBillOutstanding;
35
    }
36
37
    public function setAutoBillOutstanding(bool $autoBillOutstanding): void
38
    {
39
        $this->autoBillOutstanding = $autoBillOutstanding;
40
    }
41
42 1
    public function getPaymentFailureThreshold(): int
43
    {
44 1
        return $this->paymentFailureThreshold;
45
    }
46
47
    public function setPaymentFailureThreshold(int $paymentFailureThreshold): void
48
    {
49
        $this->paymentFailureThreshold = $paymentFailureThreshold;
50
    }
51
52 1
    public function getSetupFeeFailureAction(): string
53
    {
54 1
        return $this->setupFeeFailureAction;
55
    }
56
57
    public function setSetupFeeFailureAction(string $setupFeeFailureAction): void
58
    {
59
        $this->setupFeeFailureAction = $setupFeeFailureAction;
60
    }
61
62 4
    public function toArray(): array
63
    {
64
        return [
65 4
            'auto_bill_outstanding' => $this->autoBillOutstanding,
66 4
            'setup_fee' => $this->setupFee->toArray(),
67 4
            'setup_fee_failure_action' => $this->setupFeeFailureAction,
68 4
            'payment_failure_threshold' => $this->paymentFailureThreshold
69
        ];
70
    }
71
}
72