Passed
Pull Request — master (#1)
by Kauri
03:27
created

PaymentSchedule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Kauri\Loan;
6
7
/**
8
 * Class PaymentSchedule
9
 * @package Kauri\Loan
10
 */
11
class PaymentSchedule implements PaymentScheduleInterface
12
{
13
    /**
14
     * @var array
15
     */
16
    private $paymentDates = array();
17
18
    /**
19
     * @var PaymentScheduleConfigInterface
20
     */
21
    private $config;
22
23
    /**
24
     * PaymentSchedule constructor.
25
     * @param PaymentScheduleConfigInterface $config
26
     */
27
    public function __construct(PaymentScheduleConfigInterface $config)
28
    {
29
        $this->config = $config;
30
    }
31
32
    /**
33
     * @param \DateTimeInterface $paymentDate
34
     * @param null|int $paymentSequenceNo
35
     */
36
    public function add(\DateTimeInterface $paymentDate, int $paymentSequenceNo = null): void
37
    {
38
        $this->paymentDates[$paymentSequenceNo] = $paymentDate;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getPaymentDates(): array
45
    {
46
        return $this->paymentDates;
47
    }
48
49
    /**
50
     * @return int
51
     */
52
    public function getNoOfPayments(): int
53
    {
54
        return (int) count($this->paymentDates);
55
    }
56
57
    /**
58
     * @return PaymentScheduleConfigInterface
59
     */
60
    public function getConfig(): PaymentScheduleConfigInterface
61
    {
62
        return $this->config;
63
    }
64
65
}