The APR is essentially how much your borrowing will cost over the period of an average year, over the term of your debt. It takes into account interest charged as well as any additional fees (such as arrangement fees, or annual fees) you’ll have to pay. It also considers the frequency with which interest is charged on your borrowing, as this as an impact on how much you will pay as well.
If you want to read mroe about how this code library works, with examples, then please visit the following blog post where I explain it in detail.
https://stephenhaunts.com/2013/05/22/how-to-calculate-annual-percentage-rates-apr/