Assert LICENSE
File Size: | 2825 lines (121 kb) |
Included or required: | 2 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Assertion:: (92 methods):
eq()
eqArraySubset()
same()
notEq()
notSame()
notInArray()
integer()
float()
digit()
integerish()
boolean()
scalar()
notEmpty()
noContent()
null()
notNull()
string()
regex()
notRegex()
length()
minLength()
maxLength()
betweenLength()
startsWith()
endsWith()
contains()
notContains()
choice()
inArray()
numeric()
isResource()
isArray()
isTraversable()
isArrayAccessible()
isCountable()
keyExists()
keyNotExists()
keyIsset()
notEmptyKey()
notBlank()
isInstanceOf()
notIsInstanceOf()
subclassOf()
range()
min()
max()
file()
directory()
readable()
writeable()
email()
url()
alnum()
true()
false()
classExists()
interfaceExists()
implementsInterface()
isJsonString()
uuid()
e164()
count()
minCount()
maxCount()
__callStatic()
choicesNotEmpty()
methodExists()
isObject()
lessThan()
lessOrEqualThan()
greaterThan()
greaterOrEqualThan()
between()
betweenExclusive()
extensionLoaded()
date()
objectOrClass()
propertyExists()
propertiesExist()
version()
phpVersion()
extensionVersion()
isCallable()
satisfy()
ip()
ipv4()
ipv6()
defined()
base64()
createException()
stringify()
generateMessage()
eq($value, $value2, $message = null, string $propertyPath = null) X-Ref |
Assert that two values are equal (using ==). param: mixed $value param: mixed $value2 param: string|callable|null $message param: string|null $propertyPath return: bool |
eqArraySubset($value, $value2, $message = null, string $propertyPath = null) X-Ref |
Assert that the array contains the subset. param: mixed $value param: mixed $value2 param: string|callable|null $message param: string|null $propertyPath return: bool |
same($value, $value2, $message = null, string $propertyPath = null) X-Ref |
Assert that two values are the same (using ===). param: mixed $value param: mixed $value2 param: string|callable|null $message param: string|null $propertyPath return: bool |
notEq($value1, $value2, $message = null, string $propertyPath = null) X-Ref |
Assert that two values are not equal (using ==). param: mixed $value1 param: mixed $value2 param: string|callable|null $message param: string|null $propertyPath return: bool |
notSame($value1, $value2, $message = null, string $propertyPath = null) X-Ref |
Assert that two values are not the same (using ===). param: mixed $value1 param: mixed $value2 param: string|callable|null $message param: string|null $propertyPath return: bool |
notInArray($value, array $choices, $message = null, string $propertyPath = null) X-Ref |
Assert that value is not in array of choices. param: mixed $value param: array $choices param: string|callable|null $message param: string|null $propertyPath return: bool |
integer($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a php integer. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
float($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a php float. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
digit($value, $message = null, string $propertyPath = null) X-Ref |
Validates if an integer or integerish is a digit. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
integerish($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a php integer'ish. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
boolean($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is php boolean. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
scalar($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a PHP scalar. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
notEmpty($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is not empty. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
noContent($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is empty. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
null($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is null. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
notNull($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is not null. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
string($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a string. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
regex($value, $pattern, $message = null, string $propertyPath = null) X-Ref |
Assert that value matches a regex. param: mixed $value param: string $pattern param: string|callable|null $message param: string|null $propertyPath return: bool |
notRegex($value, $pattern, $message = null, string $propertyPath = null) X-Ref |
Assert that value does not match a regex. param: mixed $value param: string $pattern param: string|callable|null $message param: string|null $propertyPath return: bool |
length($value, $length, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string has a given length. param: mixed $value param: int $length param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
minLength($value, $minLength, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that a string is at least $minLength chars long. param: mixed $value param: int $minLength param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
maxLength($value, $maxLength, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string value is not longer than $maxLength chars. param: mixed $value param: int $maxLength param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
betweenLength($value, $minLength, $maxLength, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string length is between min and max lengths. param: mixed $value param: int $minLength param: int $maxLength param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
startsWith($string, $needle, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string starts with a sequence of chars. param: mixed $string param: string $needle param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
endsWith($string, $needle, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string ends with a sequence of chars. param: mixed $string param: string $needle param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
contains($string, $needle, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string contains a sequence of chars. param: mixed $string param: string $needle param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
notContains($string, $needle, $message = null, string $propertyPath = null, $encoding = 'utf8') X-Ref |
Assert that string does not contains a sequence of chars. param: mixed $string param: string $needle param: string|callable|null $message param: string|null $propertyPath param: string $encoding return: bool |
choice($value, array $choices, $message = null, string $propertyPath = null) X-Ref |
Assert that value is in array of choices. param: mixed $value param: array $choices param: string|callable|null $message param: string|null $propertyPath return: bool |
inArray($value, array $choices, $message = null, string $propertyPath = null) X-Ref |
Assert that value is in array of choices. This is an alias of {@see choice()}. param: mixed $value param: array $choices param: string|callable|null $message param: string|null $propertyPath return: bool |
numeric($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is numeric. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isResource($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is a resource. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isArray($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an array. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isTraversable($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an array or a traversable object. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isArrayAccessible($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an array or an array-accessible object. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isCountable($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is countable. param: array|Countable|ResourceBundle|SimpleXMLElement $value param: string|callable|null $message param: string|null $propertyPath return: bool |
keyExists($value, $key, $message = null, string $propertyPath = null) X-Ref |
Assert that key exists in an array. param: mixed $value param: string|int $key param: string|callable|null $message param: string|null $propertyPath return: bool |
keyNotExists($value, $key, $message = null, string $propertyPath = null) X-Ref |
Assert that key does not exist in an array. param: mixed $value param: string|int $key param: string|callable|null $message param: string|null $propertyPath return: bool |
keyIsset($value, $key, $message = null, string $propertyPath = null) X-Ref |
Assert that key exists in an array/array-accessible object using isset(). param: mixed $value param: string|int $key param: string|callable|null $message param: string|null $propertyPath return: bool |
notEmptyKey($value, $key, $message = null, string $propertyPath = null) X-Ref |
Assert that key exists in an array/array-accessible object and its value is not empty. param: mixed $value param: string|int $key param: string|callable|null $message param: string|null $propertyPath return: bool |
notBlank($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is not blank. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
isInstanceOf($value, $className, $message = null, string $propertyPath = null) X-Ref |
Assert that value is instance of given class-name. param: mixed $value param: string $className param: string|callable|null $message param: string|null $propertyPath return: bool |
notIsInstanceOf($value, $className, $message = null, string $propertyPath = null) X-Ref |
Assert that value is not instance of given class-name. param: mixed $value param: string $className param: string|callable|null $message param: string|null $propertyPath return: bool |
subclassOf($value, $className, $message = null, string $propertyPath = null) X-Ref |
Assert that value is subclass of given class-name. param: mixed $value param: string $className param: string|callable|null $message param: string|null $propertyPath return: bool |
range($value, $minValue, $maxValue, $message = null, string $propertyPath = null) X-Ref |
Assert that value is in range of numbers. param: mixed $value param: mixed $minValue param: mixed $maxValue param: string|callable|null $message param: string|null $propertyPath return: bool |
min($value, $minValue, $message = null, string $propertyPath = null) X-Ref |
Assert that a value is at least as big as a given limit. param: mixed $value param: mixed $minValue param: string|callable|null $message param: string|null $propertyPath return: bool |
max($value, $maxValue, $message = null, string $propertyPath = null) X-Ref |
Assert that a number is smaller as a given limit. param: mixed $value param: mixed $maxValue param: string|callable|null $message param: string|null $propertyPath return: bool |
file($value, $message = null, string $propertyPath = null) X-Ref |
Assert that a file exists. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
directory($value, $message = null, string $propertyPath = null) X-Ref |
Assert that a directory exists. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
readable($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is something readable. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
writeable($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is something writeable. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
email($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL). param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
url($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an URL. This code snipped was taken from the Symfony project and modified to the special demands of this method. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
alnum($value, $message = null, string $propertyPath = null) X-Ref |
Assert that value is alphanumeric. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
true($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is boolean True. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
false($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is boolean False. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
classExists($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the class exists. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
interfaceExists($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the interface exists. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
implementsInterface($class, $interfaceName, $message = null, string $propertyPath = null) X-Ref |
Assert that the class implements the interface. param: mixed $class param: string $interfaceName param: string|callable|null $message param: string|null $propertyPath return: bool |
isJsonString($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the given string is a valid json string. 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. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
uuid($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the given string is a valid UUID. Uses code from {@link https://github.com/ramsey/uuid} that is MIT licensed. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
e164($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the given string is a valid E164 Phone Number. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
count($countable, $count, $message = null, string $propertyPath = null) X-Ref |
Assert that the count of countable is equal to count. param: array|Countable|ResourceBundle|SimpleXMLElement $countable param: int $count param: string|callable|null $message param: string|null $propertyPath return: bool |
minCount($countable, $count, $message = null, string $propertyPath = null) X-Ref |
Assert that the countable have at least $count elements. param: array|Countable|ResourceBundle|SimpleXMLElement $countable param: int $count param: string|callable|null $message param: string|null $propertyPath return: bool |
maxCount($countable, $count, $message = null, string $propertyPath = null) X-Ref |
Assert that the countable have at most $count elements. param: array|Countable|ResourceBundle|SimpleXMLElement $countable param: int $count param: string|callable|null $message param: string|null $propertyPath return: bool |
__callStatic($method, $args) X-Ref |
static call handler to implement: - "null or assertion" delegation - "all" delegation. param: string $method param: array $args return: bool|mixed |
choicesNotEmpty(array $values, array $choices, $message = null, string $propertyPath = null) X-Ref |
Determines if the values array has every choice as key and that this choice has content. param: array $values param: array $choices param: string|callable|null $message param: string|null $propertyPath return: bool |
methodExists($value, $object, $message = null, string $propertyPath = null) X-Ref |
Determines that the named method is defined in the provided object. param: string $value param: mixed $object param: string|callable|null $message param: string|null $propertyPath return: bool |
isObject($value, $message = null, string $propertyPath = null) X-Ref |
Determines that the provided value is an object. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
lessThan($value, $limit, $message = null, string $propertyPath = null) X-Ref |
Determines if the value is less than given limit. param: mixed $value param: mixed $limit param: string|callable|null $message param: string|null $propertyPath return: bool |
lessOrEqualThan($value, $limit, $message = null, string $propertyPath = null) X-Ref |
Determines if the value is less or equal than given limit. param: mixed $value param: mixed $limit param: string|callable|null $message param: string|null $propertyPath return: bool |
greaterThan($value, $limit, $message = null, string $propertyPath = null) X-Ref |
Determines if the value is greater than given limit. param: mixed $value param: mixed $limit param: string|callable|null $message param: string|null $propertyPath return: bool |
greaterOrEqualThan($value, $limit, $message = null, string $propertyPath = null) X-Ref |
Determines if the value is greater or equal than given limit. param: mixed $value param: mixed $limit param: string|callable|null $message param: string|null $propertyPath return: bool |
between($value, $lowerLimit, $upperLimit, $message = null, string $propertyPath = null) X-Ref |
Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit. param: mixed $value param: mixed $lowerLimit param: mixed $upperLimit param: string|callable|null $message param: string $propertyPath return: bool |
betweenExclusive($value, $lowerLimit, $upperLimit, $message = null, string $propertyPath = null) X-Ref |
Assert that a value is greater than a lower limit, and less than an upper limit. param: mixed $value param: mixed $lowerLimit param: mixed $upperLimit param: string|callable|null $message param: string $propertyPath return: bool |
extensionLoaded($value, $message = null, string $propertyPath = null) X-Ref |
Assert that extension is loaded. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
date($value, $format, $message = null, string $propertyPath = null) X-Ref |
Assert that date is valid and corresponds to the given format. param: string $value param: string $format supports all of the options date(), except for the following: param: string|callable|null $message param: string|null $propertyPath return: bool |
objectOrClass($value, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is an object, or a class that exists. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
propertyExists($value, $property, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is an object or class, and that the property exists. param: mixed $value param: string $property param: string|callable|null $message param: string|null $propertyPath return: bool |
propertiesExist($value, array $properties, $message = null, string $propertyPath = null) X-Ref |
Assert that the value is an object or class, and that the properties all exist. param: mixed $value param: array $properties param: string|callable|null $message param: string|null $propertyPath return: bool |
version($version1, $operator, $version2, $message = null, string $propertyPath = null) X-Ref |
Assert comparison of two versions. param: string $version1 param: string $operator param: string $version2 param: string|callable|null $message param: string|null $propertyPath return: bool |
phpVersion($operator, $version, $message = null, string $propertyPath = null) X-Ref |
Assert on PHP version. param: string $operator param: mixed $version param: string|callable|null $message param: string|null $propertyPath return: bool |
extensionVersion($extension, $operator, $version, $message = null, string $propertyPath = null) X-Ref |
Assert that extension is loaded and a specific version is installed. param: string $extension param: string $operator param: mixed $version param: string|callable|null $message param: string|null $propertyPath return: bool |
isCallable($value, $message = null, string $propertyPath = null) X-Ref |
Determines that the provided value is callable. param: mixed $value param: string|callable|null $message param: string|null $propertyPath return: bool |
satisfy($value, $callback, $message = null, string $propertyPath = null) X-Ref |
Assert that the provided value is valid according to a callback. If the callback returns `false` the assertion will fail. param: mixed $value param: callable $callback param: string|callable|null $message param: string|null $propertyPath return: bool |
ip($value, $flag = null, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP). param: string $value param: int|null $flag param: string|callable|null $message param: string|null $propertyPath return: bool |
ipv4($value, $flag = null, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an IPv4 address (using input_filter/FILTER_VALIDATE_IP). param: string $value param: int|null $flag param: string|callable|null $message param: string|null $propertyPath return: bool |
ipv6($value, $flag = null, $message = null, string $propertyPath = null) X-Ref |
Assert that value is an IPv6 address (using input_filter/FILTER_VALIDATE_IP). param: string $value param: int|null $flag param: string|callable|null $message param: string|null $propertyPath return: bool |
defined($constant, $message = null, string $propertyPath = null) X-Ref |
Assert that a constant is defined. param: mixed $constant param: string|callable|null $message param: string|null $propertyPath return: bool |
base64($value, $message = null, string $propertyPath = null) X-Ref |
Assert that a constant is defined. param: string $value param: string|callable|null $message param: string|null $propertyPath return: bool |
createException($value, $message, $code, string $propertyPath = null, array $constraints = []) X-Ref |
Helper method that handles building the assertion failure exceptions. They are returned from this method so that the stack trace still shows the assertions method. param: mixed $value param: string|callable|null $message param: int $code param: string|null $propertyPath param: array $constraints return: mixed |
stringify($value) X-Ref |
Make a string version of a value. param: mixed $value return: string |
generateMessage($message) X-Ref |
Generate the message. param: string|callable|null $message return: string |