AbstractBillingCycle::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
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