Source of file Adjustment.php
Size: 0,956 Bytes - Last Modified: 2021-12-24T06:35:13+00:00
/var/www/docs.ssmods.com/process/src/src/Adjustment.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?php namespace SilverShop\Discounts; use Exception; /** * Stores the calculated adjustment, * and the associated object that made the adjustment. */ class Adjustment { protected $value; protected $adjuster; public function __construct($val, $adjuster = null) { $this->value = $val; $this->adjuster = $adjuster; } public static function better_of(Adjustment $i, Adjustment $j) { return $i->compareTo($j) > 0 ? $i : $j; } //biggest adjustment = best public function compareTo(Adjustment $i) { return $this->getValue() - $i->getValue(); } public function getValue() { return $this->value; } public function getAdjuster() { return $this->adjuster; } public function __tostring() { try { return (string) $this->value; } catch (Exception $exception) { return ''; } } } |