PHP code example of kaurikk / loan-payment-schedule
1. Go to this page and download the library: Download kaurikk/loan-payment-schedule library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kaurikk / loan-payment-schedule example snippets
// We have a loan for 5 years with montly payments
// How many payments loan schedule has
$noOfPayment = 5*12;
// First day of the payment schedule (first day when loan principal is out)
$startDate = new \DateTime('2000-01-01');
// What is the pattern used to generate payment dates
$dateIntervalPattern = 'P1M';
$config = new PaymentScheduleConfig($noOfPayments, $startDate, $dateIntervalPattern);
$schedule = PaymentScheduleFactory::generate($config);
var_dump($schedule instanceof PaymentScheduleInterface); // true
// Get array of payment dates
$paymentDates = $schedule->getPaymentDates();