1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PaymentGateway\PayPalSdk\Subscriptions\BillingCycles; |
4
|
|
|
|
5
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\Frequency; |
6
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\PricingSchema; |
7
|
|
|
|
8
|
|
|
abstract class AbstractBillingCycle |
9
|
|
|
{ |
10
|
|
|
protected Frequency $frequency; |
11
|
|
|
|
12
|
|
|
protected PricingSchema $pricingSchema; |
13
|
|
|
|
14
|
|
|
protected int $sequence = 1; |
15
|
|
|
|
16
|
|
|
protected int $totalCycles = 1; |
17
|
|
|
|
18
|
4 |
|
public function __construct(Frequency $frequency, PricingSchema $pricingSchema) |
19
|
|
|
{ |
20
|
4 |
|
$this->frequency = $frequency; |
21
|
4 |
|
$this->pricingSchema = $pricingSchema; |
22
|
4 |
|
} |
23
|
|
|
|
24
|
3 |
|
public function getFrequency(): Frequency |
25
|
|
|
{ |
26
|
3 |
|
return $this->frequency; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function setFrequency(Frequency $frequency): self |
30
|
|
|
{ |
31
|
|
|
$this->frequency = $frequency; |
32
|
|
|
|
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
3 |
|
public function getPricingSchema(): PricingSchema |
37
|
|
|
{ |
38
|
3 |
|
return $this->pricingSchema; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function setPricingSchema(PricingSchema $pricingSchema): self |
42
|
|
|
{ |
43
|
|
|
$this->pricingSchema = $pricingSchema; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
4 |
|
public function getSequence(): int |
49
|
|
|
{ |
50
|
4 |
|
return $this->sequence; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function setSequence(int $sequence): void |
54
|
|
|
{ |
55
|
|
|
$this->sequence = $sequence; |
56
|
|
|
} |
57
|
|
|
|
58
|
4 |
|
public function getTotalCycles(): int |
59
|
|
|
{ |
60
|
4 |
|
return $this->totalCycles; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setTotalCycles(int $totalCycles): void |
64
|
|
|
{ |
65
|
|
|
$this->totalCycles = $totalCycles; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
abstract public function getTenureType(): string; |
69
|
|
|
|
70
|
4 |
|
public function toArray(): array |
71
|
|
|
{ |
72
|
|
|
return [ |
73
|
4 |
|
'frequency' => $this->frequency->toArray(), |
74
|
4 |
|
'tenure_type' => $this->getTenureType(), |
75
|
4 |
|
'sequence' => $this->getSequence(), |
76
|
4 |
|
'total_cycles' => $this->getTotalCycles(), |
77
|
4 |
|
'pricing_scheme' => $this->pricingSchema->toArray(), |
78
|
|
|
]; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|