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
|
4 |
|
public function getSequence(): int |
25
|
|
|
{ |
26
|
4 |
|
return $this->sequence; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function setSequence(int $sequence): void |
30
|
|
|
{ |
31
|
|
|
$this->sequence = $sequence; |
32
|
|
|
} |
33
|
|
|
|
34
|
4 |
|
public function getTotalCycles(): int |
35
|
|
|
{ |
36
|
4 |
|
return $this->totalCycles; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setTotalCycles(int $totalCycles): void |
40
|
|
|
{ |
41
|
|
|
$this->totalCycles = $totalCycles; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
abstract public function getTenureType(): string; |
45
|
|
|
|
46
|
4 |
|
public function toArray(): array |
47
|
|
|
{ |
48
|
|
|
return [ |
49
|
4 |
|
'frequency' => $this->frequency->toArray(), |
50
|
4 |
|
'tenure_type' => $this->getTenureType(), |
51
|
4 |
|
'sequence' => $this->getSequence(), |
52
|
4 |
|
'total_cycles' => $this->getTotalCycles(), |
53
|
4 |
|
'pricing_scheme' => $this->pricingSchema->toArray(), |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|