Assert\Assertion::numeric PHP Метод

numeric() публичный статический Метод

Assert that value is numeric.
public static numeric ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
Результат boolean
    public static function numeric($value, $message = null, $propertyPath = null)
    {
        if (!is_numeric($value)) {
            $message = sprintf($message ?: 'Value "%s" is not numeric.', static::stringify($value));
            throw static::createException($value, $message, static::INVALID_NUMERIC, $propertyPath);
        }
        return true;
    }

Usage Example

Пример #1
0
 /**
  * @param float $minPrice
  * @param float $maxPrice
  */
 public function __construct($minPrice = 0.0, $maxPrice = 0.0)
 {
     Assertion::numeric($minPrice);
     Assertion::numeric($maxPrice);
     $this->minPrice = (double) $minPrice;
     $this->maxPrice = (double) $maxPrice;
 }
All Usage Examples Of Assert\Assertion::numeric