@ 2016-12-01T09:44:38Z <?php
/**
*
* @author Kyle @ Iezon
* @copyright (c) 2016 - 2017, Iezon
*
* Controller for Tax and Payments
*
**/
namespace Iezon\Products;
class Item {
public function __construct($product_id) {
// load product from database
}
public function cost() {
return 1000;
}
}
class TaxReturn {
const Tax = 0.2;
const TaxPercent = 20;
private $_total = 0;
private $_item = [];
public function __construct() {
$stored = $_SESSION['total'];
if(empty($stored)) return;
$this->_total = $stored;
}
public function append(Item $item) {
$this->_item[] = $item;
$this->_total = $this->_total + $item->cost();
return $this;
}
public function retrieve() {
return [ 'total' => $this->_total, 'tax_total' => (($this->_total / 100) * self::Tax) + $this->_total ];
}
}
session_start();
$iezon = [];
$iezon['payment'] = [ 'object' => new TaxReturn(), 'disclose' => [] ];
$iezon['payment']['object']->append(new Item('Some Id'));
$iezon['payment']['disclose'] = $iezon['payment']['object']->retrieve();
$money = $iezon['payment']['disclose']['tax_total'];
echo 'Total (' . TaxReturn::TaxPercent . '%) : ' . number_format(($money /100), 2, '.', ' ');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Warning: Undefined array key "total" in /in/kdnXI on line 35
Total (20%) : 10.02 Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Undefined array key "total" in /in/kdnXI on line 35
Total (20%) : 10.02 Output for 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.2.6 - 7.2.33 , 7.3.16 - 7.3.31 , 7.4.0 - 7.4.33 Notice: Undefined index: total in /in/kdnXI on line 35
Total (20%) : 10.02 Output for 7.3.32 - 7.3.33 Total (20%) : 10.02 preferences:dark mode live preview
165.42 ms | 401 KiB | 189 Q