Assert\Assertion::digit PHP Method

digit() public static method

Validates if an integer or integerish is a digit.
public static digit ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean
    public static function digit($value, $message = null, $propertyPath = null)
    {
        if (!ctype_digit((string) $value)) {
            $message = sprintf($message ?: 'Value "%s" is not a digit.', static::stringify($value));
            throw static::createException($value, $message, static::INVALID_DIGIT, $propertyPath);
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 public function testValidDigit()
 {
     Assertion::digit(1);
     Assertion::digit(0);
     Assertion::digit("0");
 }
All Usage Examples Of Assert\Assertion::digit