/loan-payment-period

Library for calculating loan periods (periods between loan payments)

Primary LanguagePHPMIT LicenseMIT

Build Status Scrutinizer Code Quality Code Coverage SensioLabsInsight

loan-payment-period

Library to generate loan payment periods based on payment schedule. Contains 3 main parts:

  • PaymentPeriodsFactory - generates payment periods based on payment schedule
  • PaymentPeriods - holds payment periods collection
  • Period - single period

Basic usage

See more about PaymentSchedule.

$paymentPeriods = PaymentPeriodsFactory::generate($paymentSchedule);

// How many periods are in collection
$numberOfPayments = $paymentPeriods->getNoOfPeriods();

// Get array of Periods from collection
$periods = $paymentPeriods->getPeriods();


// Get first period from Periods array
$firstPeriod = current($periods);

// Period start date
$firstPeriod->getStart();
// Period end date
$firstPeriod->getEnd();

Periods can have two different type of length:

  • Average: for monthly payements it's 30
  • Exact: exact different between start and end of period (from 28 to 31 or even more is adjusting logic is used)
// How long is period - average (days)
$firstPeriod->getAvgLength();

// How long is period - exact (days)
$firstPeriod->getExactLength();