1 | <?php |
||
11 | class PaymentPeriods implements PaymentPeriodsInterface |
||
12 | { |
||
13 | /** |
||
14 | * Exact payment with exact interest |
||
15 | */ |
||
16 | const CALCULATION_TYPE_EXACT = 1; |
||
17 | /** |
||
18 | * Annuity payment with exact interest |
||
19 | */ |
||
20 | const CALCULATION_TYPE_EXACT_INTEREST = 2; |
||
21 | /** |
||
22 | * Annuity payment with annuity interest |
||
23 | */ |
||
24 | const CALCULATION_TYPE_ANNUITY = 3; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $periods = array(); |
||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | private $totalLength = 0; |
||
34 | /** |
||
35 | * @var int |
||
36 | */ |
||
37 | private $averagePeriod; |
||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | private $averageTotalPeriod; |
||
42 | |||
43 | /** |
||
44 | * PaymentPeriods constructor. |
||
45 | * @param int $averagePeriod |
||
46 | */ |
||
47 | 7 | public function __construct(int $averagePeriod) |
|
51 | |||
52 | /** |
||
53 | * @param PeriodInterface $period |
||
54 | * @param int|null $sequenceNo |
||
55 | */ |
||
56 | 5 | public function add(PeriodInterface $period, int $sequenceNo = null): void |
|
65 | |||
66 | /** |
||
67 | * @param PeriodInterface $period |
||
68 | * @param float $yearlyInterestRate |
||
69 | * @param int $calculationType |
||
70 | * @return float |
||
71 | * @throws \Exception |
||
72 | */ |
||
73 | 3 | public function getRatePerPeriod( |
|
94 | |||
95 | /** |
||
96 | * @param PeriodInterface $period |
||
97 | * @param int $calculationType |
||
98 | * @return float|int |
||
99 | * @throws \Exception |
||
100 | */ |
||
101 | 6 | public function getNumberOfPeriods( |
|
123 | |||
124 | /** |
||
125 | * @return array |
||
126 | */ |
||
127 | 5 | public function getPeriods(): array |
|
131 | |||
132 | /** |
||
133 | * @return int |
||
134 | */ |
||
135 | 2 | public function getNoOfPeriods(): int |
|
139 | |||
140 | |||
141 | } |
||
142 |