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

PaymentSchedule   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 55
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A getPaymentDates() 0 4 1
A getNoOfPayments() 0 4 1
A getConfig() 0 4 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
}