## Documentation:

Attributes / Properties | ||

Property | Type | Description |

APR::APR_ABS_MIN | const float | The Absolute minimum percentage APR value the calculator can generate. By default his is set to -0.999999999999 and should not be set to -1 as this will cause the APR calculation to raise a devision by zero exception. If you would like the APR calculator to only calculate between x% & y% then you should change the value of DEFAULT_MIN_APR & DEFAULT_MAX_APR |

APR::DEFAULT_MIN_APR | const float | This is the default minimum APR value the APR calculation can generate, by default it is set to APR_ABS_MIN. |

APR::DEFAULT_MAX_APR | const float | This is the default maximum APR value the APR calculation can generate, by default it is set to PHP_INT_MAX which on a 32 bit system limits the APR to a maximum of around 214,000,000,000% (Note: Extreme APR values over 99,999% will suffer a gradual degree of inaccuracy.) |

APR::DEFAULT_PRECISION | const int | Controls the accuracy of the APR value generated and the number of decimal places output will be rounded to |

APR::MAX_ATTEMPTS | const int | The maximum number of iterations the APR calculator may perform in resolving an APR value. This is an additional failsafe to prevent an infinite loop which can occur if invalid parameters are passed. By Default this is set to 1,000 |

Principle | double | The amount borrowed less any amount retained by the creditor |

PaymentSchedule | APRPayment[] | An array of payments made for each compounding period |

CompoundingPeriods | int | The number of compounding periods per year |

Member Methods | ||

Method | Return Type | Description |

__construct | Constructor for the APR object. Accepts Principle and Compounding periods. | |

AddPayment | void | Adds a payment to the payment schedule. |

Static Member Methods | ||

Method | Return Type | Description |

APR_Simple_Annuity | float | Generates a simple Annuity with equal repayment and intervals between payments. You can also provide a setup fee and a back end fee |

ResolveAPR | float | Resolves the APR value for a payment schedule or returns FALSE |

GenerateAnnuity | APR | Generates an APR object populated with a simple payment schedule |

ShowComplianceTest | void | Shows test results required for compliance with EU Directive 98/7/EC |

**__construct(float [$principle = NULL], [float $compoundingPeriods = NULL])**

Constructs the APR object

Paramters | |

$principle | The amount loaned to the customer, if NULL the principle will be set to 0 |

$compoundingPeriods | The number of compounding periods per year. If NULL this will be set to 12 |

**void AddPayment(float $PaymentNo, float $Amount)**

Adds a payment to the payment schedule

Paramters | |

$PaymentNo | The payment number in a sequence of payments. For example, if this where payment 3 of 12 then the PaymentNo should be 3 |

$Amount | The amount for this payment |

**float APR::APR_Simple_Annuity(float $principle, float $repayment, float $term, [float $setupFee = 0], [float $backendFee = 0], [float $compoundingPeriods = NULL])**

Static utility member for resolving an APR value. Returns the APR value (float) or FALSE if an APR value cannot be found.

Paramters | |

$principle | The amount of the loan |

$repayment | The amount to be repaid each compounding period |

$term | The number of payments to be made |

$setupFee | Fee to be paid on the first month |

$backendFee | Fee to be paid on the last month |

$compoundingPeriods | Number of compounding periods per year |

**float APR::ResolveAPR(APR $loan)**

Static member to resolve the APR value for a payment schedule. Returns the APR value or FALSE

Paramters | |

$loan | A fully populated APR object |

**APR APR::GenerateAnnuity(float $principle, float $repayment, float $term, [float $setupFee = 0], [float $backendFee = 0], [float $compoundingPeriods = NULL])**

Generates an APR object and populates the required fields for a simple annuity. Returns APR object or FALSE.

Paramters | |

$principle | The amount of the loan |

$repayment | The amount to be repaid each compounding period |

$term | The number of payments to be made |

$setupFee | Fee to be paid on the first month |

$backendFee | Fee to be paid on the last month |

$compoundingPeriods | Number of compounding periods per year |