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

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

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

Usage Example

Пример #1
0
 public function testValidScalar()
 {
     Assertion::scalar("foo");
     Assertion::scalar(52);
     Assertion::scalar(12.34);
     Assertion::scalar(false);
 }
All Usage Examples Of Assert\Assertion::scalar