| @@ 13-82 (lines=70) @@ | ||
| 10 | * Class AnnuityCalculatorFactory |
|
| 11 | * @package FinanCalc\Calculators\Factories |
|
| 12 | */ |
|
| 13 | class AnnuityCalculatorFactory extends CalculatorFactoryAbstract |
|
| 14 | { |
|
| 15 | const MANUFACTURED_CLASS_NAME = 'FinanCalc\\Calculators\\AnnuityCalculator'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param $annuitySinglePaymentAmount |
|
| 19 | * @param $annuityNoOfCompoundingPeriods |
|
| 20 | * @param $annuityInterest |
|
| 21 | * @return AnnuityCalculator |
|
| 22 | */ |
|
| 23 | public function newYearlyAnnuity($annuitySinglePaymentAmount, $annuityNoOfCompoundingPeriods, $annuityInterest) |
|
| 24 | { |
|
| 25 | return $this->manufactureInstance( |
|
| 26 | [ |
|
| 27 | $annuitySinglePaymentAmount, |
|
| 28 | $annuityNoOfCompoundingPeriods, |
|
| 29 | TimeSpan::asDuration(1), |
|
| 30 | $annuityInterest |
|
| 31 | ] |
|
| 32 | ); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param $annuitySinglePaymentAmount |
|
| 37 | * @param $annuityNoOfCompoundingPeriods |
|
| 38 | * @param $annuityInterest |
|
| 39 | * @return AnnuityCalculator |
|
| 40 | */ |
|
| 41 | public function newMonthlyAnnuity($annuitySinglePaymentAmount, $annuityNoOfCompoundingPeriods, $annuityInterest) |
|
| 42 | { |
|
| 43 | return $this->manufactureInstance( |
|
| 44 | [ |
|
| 45 | $annuitySinglePaymentAmount, |
|
| 46 | $annuityNoOfCompoundingPeriods, |
|
| 47 | TimeSpan::asDuration(0, 1), |
|
| 48 | $annuityInterest |
|
| 49 | ] |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param $annuitySinglePaymentAmount |
|
| 55 | * @param $annuityNoOfCompoundingPeriods |
|
| 56 | * @param $annuityInterest |
|
| 57 | * @return AnnuityCalculator |
|
| 58 | */ |
|
| 59 | public function newDailyAnnuity($annuitySinglePaymentAmount, $annuityNoOfCompoundingPeriods, $annuityInterest) |
|
| 60 | { |
|
| 61 | return $this->manufactureInstance( |
|
| 62 | [ |
|
| 63 | $annuitySinglePaymentAmount, |
|
| 64 | $annuityNoOfCompoundingPeriods, |
|
| 65 | TimeSpan::asDuration(0, 0, 1), |
|
| 66 | $annuityInterest |
|
| 67 | ] |
|
| 68 | ); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @param $annuitySinglePaymentAmount |
|
| 73 | * @param $annuityInterest |
|
| 74 | * @return AnnuityCalculator |
|
| 75 | */ |
|
| 76 | public function newPerpetuity($annuitySinglePaymentAmount, $annuityInterest) |
|
| 77 | { |
|
| 78 | return $this->manufactureInstance( |
|
| 79 | [ |
|
| 80 | $annuitySinglePaymentAmount, |
|
| 81 | 0, |
|
| 82 | TimeSpan::asDuration(0), |
|
| 83 | $annuityInterest |
|
| 84 | ] |
|
| 85 | ); |
|
| @@ 13-87 (lines=75) @@ | ||
| 10 | * Class DebtAmortizatorFactory |
|
| 11 | * @package FinanCalc\Calculators\Factories |
|
| 12 | */ |
|
| 13 | class DebtAmortizatorFactory extends CalculatorFactoryAbstract |
|
| 14 | { |
|
| 15 | const MANUFACTURED_CLASS_NAME = 'FinanCalc\\Calculators\\DebtAmortizator'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param $debtPrincipal |
|
| 19 | * @param $debtNoOfPeriods |
|
| 20 | * @param $debtInterest |
|
| 21 | * @return DebtAmortizator |
|
| 22 | */ |
|
| 23 | public function newYearlyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest) |
|
| 24 | { |
|
| 25 | return $this->manufactureInstance( |
|
| 26 | [ |
|
| 27 | $debtPrincipal, |
|
| 28 | $debtNoOfPeriods, |
|
| 29 | TimeSpan::asDuration(1), |
|
| 30 | $debtInterest |
|
| 31 | ] |
|
| 32 | ); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param $debtPrincipal |
|
| 37 | * @param $debtNoOfPeriods |
|
| 38 | * @param $debtInterest |
|
| 39 | * @return DebtAmortizator |
|
| 40 | */ |
|
| 41 | public function newMonthlyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest) |
|
| 42 | { |
|
| 43 | return $this->manufactureInstance( |
|
| 44 | [ |
|
| 45 | $debtPrincipal, |
|
| 46 | $debtNoOfPeriods, |
|
| 47 | TimeSpan::asDuration(0, 1), |
|
| 48 | $debtInterest |
|
| 49 | ] |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param $debtPrincipal |
|
| 55 | * @param $debtNoOfPeriods |
|
| 56 | * @param $debtInterest |
|
| 57 | * @return DebtAmortizator |
|
| 58 | */ |
|
| 59 | public function newDailyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest) |
|
| 60 | { |
|
| 61 | return $this->manufactureInstance( |
|
| 62 | [ |
|
| 63 | $debtPrincipal, |
|
| 64 | $debtNoOfPeriods, |
|
| 65 | TimeSpan::asDuration(0, 0, 1), |
|
| 66 | $debtInterest |
|
| 67 | ] |
|
| 68 | ); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @param $debtPrincipal |
|
| 73 | * @param $debtNoOfPeriods |
|
| 74 | * @param $debtInterest |
|
| 75 | * @param TimeSpan $debtPeriodLength |
|
| 76 | * @return \FinanCalc\Interfaces\Calculator\CalculatorAbstract |
|
| 77 | */ |
|
| 78 | public function newDebtAmortizationCustomPeriodLength( |
|
| 79 | $debtPrincipal, |
|
| 80 | $debtNoOfPeriods, |
|
| 81 | $debtInterest, |
|
| 82 | TimeSpan $debtPeriodLength |
|
| 83 | ) { |
|
| 84 | return $this->manufactureInstance( |
|
| 85 | [ |
|
| 86 | $debtPrincipal, |
|
| 87 | $debtNoOfPeriods, |
|
| 88 | $debtPeriodLength, |
|
| 89 | $debtInterest |
|
| 90 | ] |
|