Pramda\Exception::assertNumber PHP Method

assertNumber() public static method

public static assertNumber ( integer | float $number )
$number integer | float
    public static function assertNumber($number)
    {
        if (!is_numeric($number)) {
            throw new \InvalidArgumentException("Argument is not a number");
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @return mixed|callable
  */
 public static function subtract()
 {
     $args = func_get_args();
     /**
      * Subtracts two numbers. Equivalent to `a - b` but curried.
      *
      * @category Math
      *
      * @param int|float $a The first value.
      * @param int|float $b The second value.
      *
      * @return Number The result of `$a - $b`.
      */
     $_subtract = function ($a, $b) {
         Exception::assertNumber($a);
         Exception::assertNumber($b);
         return $a - $b;
     };
     return call_user_func_array(self::curry2($_subtract), $args);
 }