Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- /**
- * ILLI
- *
- * @category ILLI_System
- * @package ILLI
- * @subpackage System
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- */
- NAMESPACE ILLI\System;
- /**
- * ILLI System Trait Numeric
- */
- TRAIT tDataTypeDecimal
- {
- # unary
- public function __bool()
- {
- return (bool) $this->__value;
- }
- public function __bool_not()
- {
- return ! (bool) $this->__value;
- }
- public function __bw_not()
- {
- return ~$this->__value;
- }
- # binary
- public function __add($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value + $numericValue;
- }
- public function __sub($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value - $numericValue;
- }
- public function __mul($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value * $numericValue;
- }
- public function __div($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value / $numericValue;
- }
- public function __mod($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value % $numericValue;
- }
- public function __sl($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value << $numericValue;
- }
- public function __sr($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value >> $numericValue;
- }
- public function __concat($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value . $numericValue;
- }
- public function __bw_or($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value | $numericValue;
- }
- public function __bw_and($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value & $numericValue;
- }
- public function __bw_xor($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value ^ $numericValue;
- }
- # binary assign
- public function __assign_add($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value += $numericValue;
- }
- public function __assign_sub($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value -= $numericValue;
- }
- public function __assign_mul($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value *= $numericValue;
- }
- public function __assign_div($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value /= $numericValue;
- }
- public function __assign_mod($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value %= $numericValue;
- }
- public function __assign_sl($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value <<= $numericValue;
- }
- public function __assign_sr($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value >>= $numericValue;
- }
- public function __assign_concat($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value .= $numericValue;
- }
- public function __assign_bw_or($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value |= $numericValue;
- }
- public function __assign_bw_and($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value &= $numericValue;
- }
- public function __assign_bw_xor($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value ^= $numericValue;
- }
- # compare
- public function __is_identical($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value === $numericValue;
- }
- public function __is_not_identical($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value !== $numericValue;
- }
- public function __is_equal($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value == $numericValue;
- }
- public function __is_not_equal($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value != $numericValue;
- }
- public function __is_smaller($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value < $numericValue;
- }
- public function __is_smaller_or_equal($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value <= $numericValue;
- }
- public function __is_greater($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value > $numericValue;
- }
- public function __is_greater_or_equal($numericValue)
- {
- if($numericValue instanceOf DataTypeNumeric)
- $numericValue->get();
- if(FALSE === is_numeric($numericValue))
- throw new ArgumentException(E::ARGUMENT_EXPECTED_NUMERIC);
- return $this->__value >= $numericValue;
- }
- public function __post_inc()
- {
- return $this->__value++;
- }
- public function __post_dec()
- {
- return $this->__value--;
- }
- public function __pre_inc()
- {
- $this->__value++;
- return $this->__value;
- }
- public function __pre_dec()
- {
- $this->__value--;
- return $this->__value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement