| Conditions | 3 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 7 | public static function generate(PaymentScheduleConfigInterface $paymentScheduleConfig): PaymentScheduleInterface |
|
| 18 | { |
||
| 19 | 7 | $schedule = new PaymentSchedule($paymentScheduleConfig); |
|
| 20 | |||
| 21 | 7 | $startDate = $paymentScheduleConfig->getStartDate(); |
|
| 22 | 7 | $dateInterval = $paymentScheduleConfig->getDateInterval(); |
|
| 23 | 7 | $noOfPayments = $paymentScheduleConfig->getNoOfPayments(); |
|
| 24 | 7 | $firstPaymentDate = $paymentScheduleConfig->getFirstPaymentDate(); |
|
| 25 | |||
| 26 | 7 | if (!is_null($firstPaymentDate)) { |
|
| 27 | 4 | $startDate = $firstPaymentDate; |
|
| 28 | 4 | $schedule->add($startDate, 1); |
|
| 29 | } |
||
| 30 | |||
| 31 | 7 | $period = new \DatePeriod($startDate, $dateInterval, ($noOfPayments - $schedule->getNoOfPayments()), |
|
| 32 | 7 | \DatePeriod::EXCLUDE_START_DATE); |
|
| 33 | |||
| 34 | 7 | foreach ($period as $iteration => $date) { |
|
| 35 | 7 | $schedule->add($date, $schedule->getNoOfPayments() + 1); |
|
| 36 | } |
||
| 37 | |||
| 38 | 7 | return $schedule; |
|
| 39 | } |
||
| 40 | } |
||
| 41 |