PHP Class Assert\Assertion

Author: Benjamin Eberlei ([email protected])
Show file Open project: beberlei/assert Class Usage Examples

Protected Properties

Property Type Description
$exceptionClass string Exception to throw when an assertion failed.

Public Methods

Method Description
__callStatic ( string $method, array $args ) : boolean | mixed static call handler to implement: - "null or assertion" delegation - "all" delegation
alnum ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is alphanumeric.
between ( mixed $value, mixed $lowerLimit, mixed $upperLimit, string $message = null, string $propertyPath = null ) : boolean Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.
betweenExclusive ( mixed $value, mixed $lowerLimit, mixed $upperLimit, string $message = null, string $propertyPath = null ) : boolean Assert that a value is greater than a lower limit, and less than an upper limit.
betweenLength ( mixed $value, integer $minLength, integer $maxLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string length is between min,max lengths.
boolean ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is php boolean
choice ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is in array of choices.
choicesNotEmpty ( array $values, array $choices, null $message = null, null $propertyPath = null ) : boolean Determines if the values array has every choice as key and that this choice has content.
classExists ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the class exists.
contains ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string contains a sequence of chars.
count ( array | Countable $countable, integer $count, string $message = null, string $propertyPath = null ) : boolean Assert that the count of countable is equal to count.
date ( string $value, string $format, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that date is valid and corresponds to the given format.
digit ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Validates if an integer or integerish is a digit.
directory ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that a directory exists
e164 ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the given string is a valid E164 Phone Number
email ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an email adress (using input_filter/FILTER_VALIDATE_EMAIL).
endsWith ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string ends with a sequence of chars.
eq ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that two values are equal (using == ).
false ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the value is boolean False.
file ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that a file exists
float ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is a php float.
greaterOrEqualThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean Determines if the value is greater or equal than given limit.
greaterThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean Determines if the value is greater than given limit.
implementsInterface ( mixed $class, string $interfaceName, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the class implements the interface
inArray ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean Alias of {@see choice()}
integer ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is a php integer.
integerish ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is a php integer'ish.
interfaceExists ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the interface exists.
ip ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP).
ipv4 ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an IPv4 address (using input_filter/FILTER_VALIDATE_IP).
ipv6 ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an IPv6 address (using input_filter/FILTER_VALIDATE_IP).
isArray ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an array.
isArrayAccessible ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an array or an array-accessible object.
isCallable ( mixed $value, null $message = null, null $propertyPath = null ) : boolean Determines that the provided value is callable.
isInstanceOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is instance of given class-name.
isJsonString ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the given string is a valid json string.
isObject ( mixed $value, null $message = null, null $propertyPath = null ) : boolean Determines that the provided value is an object.
isTraversable ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an array or a traversable object.
keyExists ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that key exists in an array
keyIsset ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that key exists in an array/array-accessible object using isset()
keyNotExists ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that key does not exist in an array
length ( mixed $value, integer $length, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string has a given length.
lessOrEqualThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean Determines if the value is less or than given limit.
lessThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean Determines if the value is less than given limit.
max ( mixed $value, mixed $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that a number is smaller as a given limit
maxLength ( mixed $value, integer $maxLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string value is not longer than $maxLength chars.
methodExists ( string $value, mixed $object, null $message = null, null $propertyPath = null ) : boolean Determines that the named method is defined in the provided object.
min ( mixed $value, mixed $minValue, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that a value is at least as big as a given limit
minLength ( mixed $value, integer $minLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that a string is at least $minLength chars long.
noContent ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is empty
notBlank ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is not blank
notEmpty ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is not empty
notEmptyKey ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that key exists in an array/array-accessible object and it's value is not empty.
notEq ( mixed $value1, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that two values are not equal (using == ).
notInArray ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is not in array of choices.
notIsInstanceOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is not instance of given class-name.
notNull ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is not null
notSame ( mixed $value1, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that two values are not the same (using === ).
null ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is null
numeric ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is numeric.
range ( mixed $value, integer $minValue, integer $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is in range of numbers.
readable ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the value is something readable
regex ( mixed $value, string $pattern, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value matches a regex
same ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that two values are the same (using ===).
satisfy ( mixed $value, callable $callback, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the provided value is valid according to a callback.
scalar ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is a PHP scalar
startsWith ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean Assert that string starts with a sequence of chars.
string ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is a string
subclassOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is subclass of given class-name.
true ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the value is boolean True.
url ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that value is an URL.
uuid ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the given string is a valid UUID
writeable ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean Assert that the value is something writeable

Protected Methods

Method Description
createException ( mixed $value, string $message, integer $code, string | null $propertyPath, array $constraints = [] ) : mixed Helper method that handles building the assertion failure exceptions.
stringify ( mixed $value ) : string Make a string version of a value.

Method Details

__callStatic() public static method

static call handler to implement: - "null or assertion" delegation - "all" delegation
public static __callStatic ( string $method, array $args ) : boolean | mixed
$method string
$args array
return boolean | mixed

alnum() public static method

Assert that value is alphanumeric.
public static alnum ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

between() public static method

Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.
public static between ( mixed $value, mixed $lowerLimit, mixed $upperLimit, string $message = null, string $propertyPath = null ) : boolean
$value mixed
$lowerLimit mixed
$upperLimit mixed
$message string
$propertyPath string
return boolean

betweenExclusive() public static method

Assert that a value is greater than a lower limit, and less than an upper limit.
public static betweenExclusive ( mixed $value, mixed $lowerLimit, mixed $upperLimit, string $message = null, string $propertyPath = null ) : boolean
$value mixed
$lowerLimit mixed
$upperLimit mixed
$message string
$propertyPath string
return boolean

betweenLength() public static method

Assert that string length is between min,max lengths.
public static betweenLength ( mixed $value, integer $minLength, integer $maxLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$minLength integer
$maxLength integer
$message string | null
$propertyPath string | null
$encoding string
return boolean

boolean() public static method

Assert that value is php boolean
public static boolean ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

choice() public static method

Assert that value is in array of choices.
public static choice ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$choices array
$message string | null
$propertyPath string | null
return boolean

choicesNotEmpty() public static method

Determines if the values array has every choice as key and that this choice has content.
public static choicesNotEmpty ( array $values, array $choices, null $message = null, null $propertyPath = null ) : boolean
$values array
$choices array
$message null
$propertyPath null
return boolean

classExists() public static method

Assert that the class exists.
public static classExists ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

contains() public static method

Assert that string contains a sequence of chars.
public static contains ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$string mixed
$needle string
$message string | null
$propertyPath string | null
$encoding string
return boolean

count() public static method

Assert that the count of countable is equal to count.
public static count ( array | Countable $countable, integer $count, string $message = null, string $propertyPath = null ) : boolean
$countable array | Countable
$count integer
$message string
$propertyPath string
return boolean

createException() protected static method

They are returned from this method so that the stack trace still shows the assertions method.
protected static createException ( mixed $value, string $message, integer $code, string | null $propertyPath, array $constraints = [] ) : mixed
$value mixed
$message string
$code integer
$propertyPath string | null
$constraints array
return mixed

date() public static method

Assert that date is valid and corresponds to the given format.
public static date ( string $value, string $format, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$format string supports all of the options date(), except for the following: N, w, W, t, L, o, B, a, A, g, h, I, O, P, Z, c, r.
$message string | null
$propertyPath string | null
return boolean

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

directory() public static method

Assert that a directory exists
public static directory ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

e164() public static method

Assert that the given string is a valid E164 Phone Number
public static e164 ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

email() public static method

Assert that value is an email adress (using input_filter/FILTER_VALIDATE_EMAIL).
public static email ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

endsWith() public static method

Assert that string ends with a sequence of chars.
public static endsWith ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$string mixed
$needle string
$message string | null
$propertyPath string | null
$encoding string
return boolean

eq() public static method

Assert that two values are equal (using == ).
public static eq ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$value2 mixed
$message string | null
$propertyPath string | null
return boolean

false() public static method

Assert that the value is boolean False.
public static false ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

file() public static method

Assert that a file exists
public static file ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

float() public static method

Assert that value is a php float.
public static float ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

greaterOrEqualThan() public static method

Determines if the value is greater or equal than given limit.
public static greaterOrEqualThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$limit mixed
$message null
$propertyPath null
return boolean

greaterThan() public static method

Determines if the value is greater than given limit.
public static greaterThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$limit mixed
$message null
$propertyPath null
return boolean

implementsInterface() public static method

Assert that the class implements the interface
public static implementsInterface ( mixed $class, string $interfaceName, string | null $message = null, string | null $propertyPath = null ) : boolean
$class mixed
$interfaceName string
$message string | null
$propertyPath string | null
return boolean

inArray() public static method

Alias of {@see choice()}
public static inArray ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$choices array
$message string | null
$propertyPath string | null
return boolean

integer() public static method

Assert that value is a php integer.
public static integer ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

integerish() public static method

Assert that value is a php integer'ish.
public static integerish ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

interfaceExists() public static method

Assert that the interface exists.
public static interfaceExists ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

ip() public static method

Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP).
public static ip ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$flag null | integer
$message string | null
$propertyPath string | null
return boolean

ipv4() public static method

Assert that value is an IPv4 address (using input_filter/FILTER_VALIDATE_IP).
public static ipv4 ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$flag null | integer
$message string | null
$propertyPath string | null
return boolean

ipv6() public static method

Assert that value is an IPv6 address (using input_filter/FILTER_VALIDATE_IP).
public static ipv6 ( string $value, null | integer $flag = null, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$flag null | integer
$message string | null
$propertyPath string | null
return boolean

isArray() public static method

Assert that value is an array.
public static isArray ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

isArrayAccessible() public static method

Assert that value is an array or an array-accessible object.
public static isArrayAccessible ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

isCallable() public static method

Determines that the provided value is callable.
public static isCallable ( mixed $value, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$message null
$propertyPath null
return boolean

isInstanceOf() public static method

Assert that value is instance of given class-name.
public static isInstanceOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$className string
$message string | null
$propertyPath string | null
return boolean

isJsonString() public static method

NOTICE: Since this does a json_decode to determine its validity you probably should consider, when using the variable content afterwards, just to decode and check for yourself instead of using this assertion.
public static isJsonString ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

isObject() public static method

Determines that the provided value is an object.
public static isObject ( mixed $value, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$message null
$propertyPath null
return boolean

isTraversable() public static method

Assert that value is an array or a traversable object.
public static isTraversable ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

keyExists() public static method

Assert that key exists in an array
public static keyExists ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
return boolean

keyIsset() public static method

Assert that key exists in an array/array-accessible object using isset()
public static keyIsset ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
return boolean

keyNotExists() public static method

Assert that key does not exist in an array
public static keyNotExists ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
return boolean

length() public static method

Assert that string has a given length.
public static length ( mixed $value, integer $length, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$length integer
$message string | null
$propertyPath string | null
$encoding string
return boolean

lessOrEqualThan() public static method

Determines if the value is less or than given limit.
public static lessOrEqualThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$limit mixed
$message null
$propertyPath null
return boolean

lessThan() public static method

Determines if the value is less than given limit.
public static lessThan ( mixed $value, mixed $limit, null $message = null, null $propertyPath = null ) : boolean
$value mixed
$limit mixed
$message null
$propertyPath null
return boolean

max() public static method

Assert that a number is smaller as a given limit
public static max ( mixed $value, mixed $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$maxValue mixed
$message string | null
$propertyPath string | null
return boolean

maxLength() public static method

Assert that string value is not longer than $maxLength chars.
public static maxLength ( mixed $value, integer $maxLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$maxLength integer
$message string | null
$propertyPath string | null
$encoding string
return boolean

methodExists() public static method

Determines that the named method is defined in the provided object.
public static methodExists ( string $value, mixed $object, null $message = null, null $propertyPath = null ) : boolean
$value string
$object mixed
$message null
$propertyPath null
return boolean

min() public static method

Assert that a value is at least as big as a given limit
public static min ( mixed $value, mixed $minValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$minValue mixed
$message string | null
$propertyPath string | null
return boolean

minLength() public static method

Assert that a string is at least $minLength chars long.
public static minLength ( mixed $value, integer $minLength, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$value mixed
$minLength integer
$message string | null
$propertyPath string | null
$encoding string
return boolean

noContent() public static method

Assert that value is empty
public static noContent ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

notBlank() public static method

Assert that value is not blank
public static notBlank ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

notEmpty() public static method

Assert that value is not empty
public static notEmpty ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

notEmptyKey() public static method

Assert that key exists in an array/array-accessible object and it's value is not empty.
public static notEmptyKey ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
return boolean

notEq() public static method

Assert that two values are not equal (using == ).
public static notEq ( mixed $value1, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value1 mixed
$value2 mixed
$message string | null
$propertyPath string | null
return boolean

notInArray() public static method

Assert that value is not in array of choices.
public static notInArray ( mixed $value, array $choices, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$choices array
$message string | null
$propertyPath string | null
return boolean

notIsInstanceOf() public static method

Assert that value is not instance of given class-name.
public static notIsInstanceOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$className string
$message string | null
$propertyPath string | null
return boolean

notNull() public static method

Assert that value is not null
public static notNull ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

notSame() public static method

Assert that two values are not the same (using === ).
public static notSame ( mixed $value1, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value1 mixed
$value2 mixed
$message string | null
$propertyPath string | null
return boolean

null() public static method

Assert that value is null
public static null ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

numeric() public static method

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
return boolean

range() public static method

Assert that value is in range of numbers.
public static range ( mixed $value, integer $minValue, integer $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$minValue integer
$maxValue integer
$message string | null
$propertyPath string | null
return boolean

readable() public static method

Assert that the value is something readable
public static readable ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

regex() public static method

Assert that value matches a regex
public static regex ( mixed $value, string $pattern, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$pattern string
$message string | null
$propertyPath string | null
return boolean

same() public static method

Assert that two values are the same (using ===).
public static same ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$value2 mixed
$message string | null
$propertyPath string | null
return boolean

satisfy() public static method

If the callback returns false the assertion will fail.
public static satisfy ( mixed $value, callable $callback, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$callback callable
$message string | null
$propertyPath string | null
return boolean

scalar() public static method

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
return boolean

startsWith() public static method

Assert that string starts with a sequence of chars.
public static startsWith ( mixed $string, string $needle, string | null $message = null, string | null $propertyPath = null, string $encoding = 'utf8' ) : boolean
$string mixed
$needle string
$message string | null
$propertyPath string | null
$encoding string
return boolean

string() public static method

Assert that value is a string
public static string ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

stringify() protected static method

Make a string version of a value.
protected static stringify ( mixed $value ) : string
$value mixed
return string

subclassOf() public static method

Assert that value is subclass of given class-name.
public static subclassOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$className string
$message string | null
$propertyPath string | null
return boolean

true() public static method

Assert that the value is boolean True.
public static true ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

url() public static method

This code snipped was taken from the Symfony project and modified to the special demands of this method.
public static url ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean

uuid() public static method

Uses code from {@link https://github.com/ramsey/uuid} that is MIT licensed.
public static uuid ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

writeable() public static method

Assert that the value is something writeable
public static writeable ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean

Property Details

$exceptionClass protected static property

Exception to throw when an assertion failed.
protected static string $exceptionClass
return string