PHP code example of springy-framework / installment-calc
1. Go to this page and download the library: Download springy-framework/installment-calc 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/ */
springy-framework / installment-calc example snippets
eates the object. Only the principal value is requered in constructor.
$installment = new Springy\InstallmentCalc(
1000,
0.5,
Springy\InstallmentCalc::FORMULA_COMPOUND
);
/*
Interst formula constants explained
Springy\InstallmentCalc::FORMULA_SIMPLE - Simple interest
Springy\InstallmentCalc::FORMULA_COMPOUND - Compound interest
Springy\InstallmentCalc::FORMULA_BCB - Brazilian Central Bank interset formula
*/
// Gets future amount for 12 months
echo $installment->getFutureAmount(12);
// Gets total interest for 12 months
echo $installment->getInterest(12);
// Gets monthly installment for 12 months
echo $installment->getMonthlyInstallment(12);
// Gets current principal amount
echo $installment->getPrincipalAmount();
// Gets current interest formula method
echo $installment->getFormulaMethod();
// Gets current interes rate
echo $installment->getInterestRate();
// Changes the principal amount value
$installment->setPrincipalAmount(1999.99);
// Changes the interest formula value
$installment->setFormulaMethod(Springy\InstallmentCalc::FORMULA_SIMPLE);
// Changes the interest rate value
$installment->setInteresRate(1.99);