1. Go to this page and download the library: Download ranskills/billing-boss 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/ */
ranskills / billing-boss example snippets
// 1. Import the gBoss;
use BillingBoss\BillContext;
// 2. Define the context to be interpreted
$ctxt = new BillContext(1000, '2.5%, 1 - *');
// 3. Pass the context to be interpreted
$bill = BillingBoss::interpret($ctxt);
// $bill = 25.00
namespace YourProject\BillingBoss\Interpreter;
use BillingBoss\AbstractBillInterpreter;
class SquareBillInterpreter extends AbstractBillInterpreter {
public function __construct() {
// Defining the regular expression to match the notation ^2
parent::__construct('/^\^2$/');
}
public function interpret(BillContext context) {
if (!isValid(context)) return 0.0;
return context.getAmount() * context.getAmount();
}
}
$ctxt = new BillContext(50, "^2");
double bill = BillingBoss::bill($ctxt);
// bill will be 2500
$ctxt.setAmount(10);
bill = BillingBoss::bill($ctxt);
// bill will be 100
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.