Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Assert\Assertion Class Reference

Assert library. More...

Static Public Member Functions

static __callStatic ($method, $args)
 static call handler to implement:
 
static alnum ($value, $message=null, string $propertyPath=null)
 Assert that value is alphanumeric.
 
static base64 ($value, $message=null, string $propertyPath=null)
 Assert that a constant is defined.
 
static between ($value, $lowerLimit, $upperLimit, $message=null, string $propertyPath=null)
 Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.
 
static betweenExclusive ($value, $lowerLimit, $upperLimit, $message=null, string $propertyPath=null)
 Assert that a value is greater than a lower limit, and less than an upper limit.
 
static betweenLength ($value, $minLength, $maxLength, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string length is between min and max lengths.
 
static boolean ($value, $message=null, string $propertyPath=null)
 Assert that value is php boolean.
 
static choice ($value, array $choices, $message=null, string $propertyPath=null)
 Assert that value is in array of choices.
 
static choicesNotEmpty (array $values, array $choices, $message=null, string $propertyPath=null)
 Determines if the values array has every choice as key and that this choice has content.
 
static classExists ($value, $message=null, string $propertyPath=null)
 Assert that the class exists.
 
static contains ($string, $needle, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string contains a sequence of chars.
 
static count ($countable, $count, $message=null, string $propertyPath=null)
 Assert that the count of countable is equal to count.
 
static date ($value, $format, $message=null, string $propertyPath=null)
 Assert that date is valid and corresponds to the given format.
 
static defined ($constant, $message=null, string $propertyPath=null)
 Assert that a constant is defined.
 
static digit ($value, $message=null, string $propertyPath=null)
 Validates if an integer or integerish is a digit.
 
static directory ($value, $message=null, string $propertyPath=null)
 Assert that a directory exists.
 
static e164 ($value, $message=null, string $propertyPath=null)
 Assert that the given string is a valid E164 Phone Number.
 
static email ($value, $message=null, string $propertyPath=null)
 Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL).
 
static endsWith ($string, $needle, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string ends with a sequence of chars.
 
static eq ($value, $value2, $message=null, string $propertyPath=null)
 Assert that two values are equal (using ==).
 
static eqArraySubset ($value, $value2, $message=null, string $propertyPath=null)
 Assert that the array contains the subset.
 
static extensionLoaded ($value, $message=null, string $propertyPath=null)
 Assert that extension is loaded.
 
static extensionVersion ($extension, $operator, $version, $message=null, string $propertyPath=null)
 Assert that extension is loaded and a specific version is installed.
 
static false ($value, $message=null, string $propertyPath=null)
 Assert that the value is boolean False.
 
static file ($value, $message=null, string $propertyPath=null)
 Assert that a file exists.
 
static float ($value, $message=null, string $propertyPath=null)
 Assert that value is a php float.
 
static greaterOrEqualThan ($value, $limit, $message=null, string $propertyPath=null)
 Determines if the value is greater or equal than given limit.
 
static greaterThan ($value, $limit, $message=null, string $propertyPath=null)
 Determines if the value is greater than given limit.
 
static implementsInterface ($class, $interfaceName, $message=null, string $propertyPath=null)
 Assert that the class implements the interface.
 
static inArray ($value, array $choices, $message=null, string $propertyPath=null)
 Assert that value is in array of choices.
 
static integer ($value, $message=null, string $propertyPath=null)
 Assert that value is a php integer.
 
static integerish ($value, $message=null, string $propertyPath=null)
 Assert that value is a php integer'ish.
 
static interfaceExists ($value, $message=null, string $propertyPath=null)
 Assert that the interface exists.
 
static ip ($value, $flag=null, $message=null, string $propertyPath=null)
 Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP).
 
static ipv4 ($value, $flag=null, $message=null, string $propertyPath=null)
 Assert that value is an IPv4 address (using input_filter/FILTER_VALIDATE_IP).
 
static ipv6 ($value, $flag=null, $message=null, string $propertyPath=null)
 Assert that value is an IPv6 address (using input_filter/FILTER_VALIDATE_IP).
 
static isArray ($value, $message=null, string $propertyPath=null)
 Assert that value is an array.
 
static isArrayAccessible ($value, $message=null, string $propertyPath=null)
 Assert that value is an array or an array-accessible object.
 
static isCallable ($value, $message=null, string $propertyPath=null)
 Determines that the provided value is callable.
 
static isCountable ($value, $message=null, string $propertyPath=null)
 Assert that value is countable.
 
static isInstanceOf ($value, $className, $message=null, string $propertyPath=null)
 Assert that value is instance of given class-name.
 
static isJsonString ($value, $message=null, string $propertyPath=null)
 Assert that the given string is a valid json string.
 
static isObject ($value, $message=null, string $propertyPath=null)
 Determines that the provided value is an object.
 
static isResource ($value, $message=null, string $propertyPath=null)
 Assert that value is a resource.
 
static isTraversable ($value, $message=null, string $propertyPath=null)
 Assert that value is an array or a traversable object.
 
static keyExists ($value, $key, $message=null, string $propertyPath=null)
 Assert that key exists in an array.
 
static keyIsset ($value, $key, $message=null, string $propertyPath=null)
 Assert that key exists in an array/array-accessible object using isset().
 
static keyNotExists ($value, $key, $message=null, string $propertyPath=null)
 Assert that key does not exist in an array.
 
static length ($value, $length, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string has a given length.
 
static lessOrEqualThan ($value, $limit, $message=null, string $propertyPath=null)
 Determines if the value is less or equal than given limit.
 
static lessThan ($value, $limit, $message=null, string $propertyPath=null)
 Determines if the value is less than given limit.
 
static max ($value, $maxValue, $message=null, string $propertyPath=null)
 Assert that a number is smaller as a given limit.
 
static maxCount ($countable, $count, $message=null, string $propertyPath=null)
 Assert that the countable have at most $count elements.
 
static maxLength ($value, $maxLength, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string value is not longer than $maxLength chars.
 
static methodExists ($value, $object, $message=null, string $propertyPath=null)
 Determines that the named method is defined in the provided object.
 
static min ($value, $minValue, $message=null, string $propertyPath=null)
 Assert that a value is at least as big as a given limit.
 
static minCount ($countable, $count, $message=null, string $propertyPath=null)
 Assert that the countable have at least $count elements.
 
static minLength ($value, $minLength, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that a string is at least $minLength chars long.
 
static noContent ($value, $message=null, string $propertyPath=null)
 Assert that value is empty.
 
static notBlank ($value, $message=null, string $propertyPath=null)
 Assert that value is not blank.
 
static notContains ($string, $needle, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string does not contains a sequence of chars.
 
static notEmpty ($value, $message=null, string $propertyPath=null)
 Assert that value is not empty.
 
static notEmptyKey ($value, $key, $message=null, string $propertyPath=null)
 Assert that key exists in an array/array-accessible object and its value is not empty.
 
static notEq ($value1, $value2, $message=null, string $propertyPath=null)
 Assert that two values are not equal (using ==).
 
static notInArray ($value, array $choices, $message=null, string $propertyPath=null)
 Assert that value is not in array of choices.
 
static notIsInstanceOf ($value, $className, $message=null, string $propertyPath=null)
 Assert that value is not instance of given class-name.
 
static notNull ($value, $message=null, string $propertyPath=null)
 Assert that value is not null.
 
static notRegex ($value, $pattern, $message=null, string $propertyPath=null)
 Assert that value does not match a regex.
 
static notSame ($value1, $value2, $message=null, string $propertyPath=null)
 Assert that two values are not the same (using ===).
 
static null ($value, $message=null, string $propertyPath=null)
 Assert that value is null.
 
static numeric ($value, $message=null, string $propertyPath=null)
 Assert that value is numeric.
 
static objectOrClass ($value, $message=null, string $propertyPath=null)
 Assert that the value is an object, or a class that exists.
 
static phpVersion ($operator, $version, $message=null, string $propertyPath=null)
 Assert on PHP version.
 
static propertiesExist ($value, array $properties, $message=null, string $propertyPath=null)
 Assert that the value is an object or class, and that the properties all exist.
 
static propertyExists ($value, $property, $message=null, string $propertyPath=null)
 Assert that the value is an object or class, and that the property exists.
 
static range ($value, $minValue, $maxValue, $message=null, string $propertyPath=null)
 Assert that value is in range of numbers.
 
static readable ($value, $message=null, string $propertyPath=null)
 Assert that the value is something readable.
 
static regex ($value, $pattern, $message=null, string $propertyPath=null)
 Assert that value matches a regex.
 
static same ($value, $value2, $message=null, string $propertyPath=null)
 Assert that two values are the same (using ===).
 
static satisfy ($value, $callback, $message=null, string $propertyPath=null)
 Assert that the provided value is valid according to a callback.
 
static scalar ($value, $message=null, string $propertyPath=null)
 Assert that value is a PHP scalar.
 
static startsWith ($string, $needle, $message=null, string $propertyPath=null, $encoding='utf8')
 Assert that string starts with a sequence of chars.
 
static string ($value, $message=null, string $propertyPath=null)
 Assert that value is a string.
 
static subclassOf ($value, $className, $message=null, string $propertyPath=null)
 Assert that value is subclass of given class-name.
 
static true ($value, $message=null, string $propertyPath=null)
 Assert that the value is boolean True.
 
static url ($value, $message=null, string $propertyPath=null)
 Assert that value is an URL.
 
static uuid ($value, $message=null, string $propertyPath=null)
 Assert that the given string is a valid UUID.
 
static version ($version1, $operator, $version2, $message=null, string $propertyPath=null)
 Assert comparison of two versions.
 
static writeable ($value, $message=null, string $propertyPath=null)
 Assert that the value is something writeable.
 

Public Attributes

const INTERFACE_NOT_IMPLEMENTED = 202
 
const INVALID_ALNUM = 31
 
const INVALID_ARRAY = 24
 
const INVALID_ARRAY_ACCESSIBLE = 45
 
const INVALID_BASE64 = 49
 
const INVALID_BETWEEN = 219
 
const INVALID_BETWEEN_EXCLUSIVE = 220
 
const INVALID_BOOLEAN = 13
 
const INVALID_CALLABLE = 215
 
const INVALID_CHOICE = 22
 
const INVALID_CLASS = 105
 
const INVALID_CONSTANT = 221
 
const INVALID_COUNT = 41
 
const INVALID_COUNTABLE = 226
 
const INVALID_DATE = 214
 
const INVALID_DIGIT = 11
 
const INVALID_DIRECTORY = 101
 
const INVALID_E164 = 48
 
const INVALID_EMAIL = 201
 
const INVALID_EQ = 33
 
const INVALID_EXTENSION = 222
 
const INVALID_FALSE = 38
 
const INVALID_FILE = 102
 
const INVALID_FILE_NOT_EXISTS = 107
 
const INVALID_FLOAT = 9
 
const INVALID_GREATER = 212
 
const INVALID_GREATER_OR_EQUAL = 213
 
const INVALID_INSTANCE_OF = 28
 
const INVALID_INTEGER = 10
 
const INVALID_INTEGERISH = 12
 
const INVALID_INTERFACE = 106
 
const INVALID_IP = 218
 
const INVALID_JSON_STRING = 206
 
const INVALID_KEY_EXISTS = 26
 
const INVALID_KEY_ISSET = 46
 
const INVALID_KEY_NOT_EXISTS = 216
 
const INVALID_LENGTH = 37
 
const INVALID_LESS = 210
 
const INVALID_LESS_OR_EQUAL = 211
 
const INVALID_MAX = 36
 
const INVALID_MAX_COUNT = 228
 
const INVALID_MAX_LENGTH = 19
 
const INVALID_METHOD = 208
 
const INVALID_MIN = 35
 
const INVALID_MIN_COUNT = 227
 
const INVALID_MIN_LENGTH = 18
 
const INVALID_NOT_BLANK = 27
 
const INVALID_NOT_EQ = 42
 
const INVALID_NOT_INSTANCE_OF = 204
 
const INVALID_NOT_REGEX = 50
 
const INVALID_NOT_SAME = 43
 
const INVALID_NUMERIC = 23
 
const INVALID_OBJECT = 207
 
const INVALID_PROPERTY = 224
 
const INVALID_RANGE = 30
 
const INVALID_READABLE = 103
 
const INVALID_REGEX = 17
 
const INVALID_RESOURCE = 225
 
const INVALID_SAME = 34
 
const INVALID_SATISFY = 217
 
const INVALID_SCALAR = 209
 
const INVALID_STRING = 16
 
const INVALID_STRING_CONTAINS = 21
 
const INVALID_STRING_END = 39
 
const INVALID_STRING_NOT_CONTAINS = 229
 
const INVALID_STRING_START = 20
 
const INVALID_SUBCLASS_OF = 29
 
const INVALID_TRAVERSABLE = 44
 
const INVALID_TRUE = 32
 
const INVALID_URL = 203
 
const INVALID_UUID = 40
 
const INVALID_VALUE_IN_ARRAY = 47
 
const INVALID_VERSION = 223
 
const INVALID_WRITEABLE = 104
 
const VALUE_EMPTY = 14
 
const VALUE_NOT_EMPTY = 205
 
const VALUE_NOT_NULL = 25
 
const VALUE_NULL = 15
 

Static Protected Member Functions

static createException ($value, $message, $code, string $propertyPath=null, array $constraints=[])
 Helper method that handles building the assertion failure exceptions.
 
static generateMessage ($message)
 Generate the message.
 
static stringify ($value)
 Make a string version of a value.
 

Static Protected Attributes

static string $exceptionClass = InvalidArgumentException::class
 Exception to throw when an assertion failed.
 

Detailed Description

Assert library.

Author
Benjamin Eberlei konta.nosp@m.kt@b.nosp@m.eberl.nosp@m.ei.d.nosp@m.e

@method static bool allAlnum(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is alphanumeric for all values. @method static bool allBase64(string $value, string|callable $message = null, string $propertyPath = null) Assert that a constant is defined for all values. @method static bool allBetween(mixed $value, mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit for all values. @method static bool allBetweenExclusive(mixed $value, mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater than a lower limit, and less than an upper limit for all values. @method static bool allBetweenLength(mixed $value, int $minLength, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string length is between min and max lengths for all values. @method static bool allBoolean(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is php boolean for all values. @method static bool allChoice(mixed $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices for all values. @method static bool allChoicesNotEmpty(array $values, array $choices, string|callable $message = null, string $propertyPath = null) Determines if the values array has every choice as key and that this choice has content for all values. @method static bool allClassExists(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the class exists for all values. @method static bool allContains(mixed $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string contains a sequence of chars for all values. @method static bool allCount(array|Countable|ResourceBundle|SimpleXMLElement $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the count of countable is equal to count for all values. @method static bool allDate(string $value, string $format, string|callable $message = null, string $propertyPath = null) Assert that date is valid and corresponds to the given format for all values. @method static bool allDefined(mixed $constant, string|callable $message = null, string $propertyPath = null) Assert that a constant is defined for all values. @method static bool allDigit(mixed $value, string|callable $message = null, string $propertyPath = null) Validates if an integer or integerish is a digit for all values. @method static bool allDirectory(string $value, string|callable $message = null, string $propertyPath = null) Assert that a directory exists for all values. @method static bool allE164(string $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid E164 Phone Number for all values. @method static bool allEmail(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL) for all values. @method static bool allEndsWith(mixed $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string ends with a sequence of chars for all values. @method static bool allEq(mixed $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are equal (using ==) for all values. @method static bool allEqArraySubset(mixed $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that the array contains the subset for all values. @method static bool allExtensionLoaded(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded for all values. @method static bool allExtensionVersion(string $extension, string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded and a specific version is installed for all values. @method static bool allFalse(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the value is boolean False for all values. @method static bool allFile(string $value, string|callable $message = null, string $propertyPath = null) Assert that a file exists for all values. @method static bool allFloat(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php float for all values. @method static bool allGreaterOrEqualThan(mixed $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater or equal than given limit for all values. @method static bool allGreaterThan(mixed $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater than given limit for all values. @method static bool allImplementsInterface(mixed $class, string $interfaceName, string|callable $message = null, string $propertyPath = null) Assert that the class implements the interface for all values. @method static bool allInArray(mixed $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. This is an alias of Assertion\choice() for all values. @method static bool allInteger(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php integer for all values. @method static bool allIntegerish(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php integer'ish for all values. @method static bool allInterfaceExists(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the interface exists for all values. @method static bool allIp(string $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 or IPv6 address for all values. @method static bool allIpv4(string $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 address for all values. @method static bool allIpv6(string $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv6 address for all values. @method static bool allIsArray(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array for all values. @method static bool allIsArrayAccessible(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array or an array-accessible object for all values. @method static bool allIsCallable(mixed $value, string|callable $message = null, string $propertyPath = null) Determines that the provided value is callable for all values. @method static bool allIsCountable(array|Countable|ResourceBundle|SimpleXMLElement $value, string|callable $message = null, string $propertyPath = null) Assert that value is countable for all values. @method static bool allIsInstanceOf(mixed $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is instance of given class-name for all values. @method static bool allIsJsonString(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid json string for all values. @method static bool allIsObject(mixed $value, string|callable $message = null, string $propertyPath = null) Determines that the provided value is an object for all values. @method static bool allIsResource(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a resource for all values. @method static bool allIsTraversable(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array or a traversable object for all values. @method static bool allKeyExists(mixed $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array for all values. @method static bool allKeyIsset(mixed $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object using isset() for all values. @method static bool allKeyNotExists(mixed $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key does not exist in an array for all values. @method static bool allLength(mixed $value, int $length, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string has a given length for all values. @method static bool allLessOrEqualThan(mixed $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less or equal than given limit for all values. @method static bool allLessThan(mixed $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less than given limit for all values. @method static bool allMax(mixed $value, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that a number is smaller as a given limit for all values. @method static bool allMaxCount(array|Countable|ResourceBundle|SimpleXMLElement $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at most $count elements for all values. @method static bool allMaxLength(mixed $value, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string value is not longer than $maxLength chars for all values. @method static bool allMethodExists(string $value, mixed $object, string|callable $message = null, string $propertyPath = null) Determines that the named method is defined in the provided object for all values. @method static bool allMin(mixed $value, mixed $minValue, string|callable $message = null, string $propertyPath = null) Assert that a value is at least as big as a given limit for all values. @method static bool allMinCount(array|Countable|ResourceBundle|SimpleXMLElement $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at least $count elements for all values. @method static bool allMinLength(mixed $value, int $minLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that a string is at least $minLength chars long for all values. @method static bool allNoContent(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is empty for all values. @method static bool allNotBlank(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is not blank for all values. @method static bool allNotContains(mixed $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string does not contains a sequence of chars for all values. @method static bool allNotEmpty(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is not empty for all values. @method static bool allNotEmptyKey(mixed $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object and its value is not empty for all values. @method static bool allNotEq(mixed $value1, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not equal (using ==) for all values. @method static bool allNotInArray(mixed $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is not in array of choices for all values. @method static bool allNotIsInstanceOf(mixed $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is not instance of given class-name for all values. @method static bool allNotNull(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is not null for all values. @method static bool allNotRegex(mixed $value, string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value does not match a regex for all values. @method static bool allNotSame(mixed $value1, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not the same (using ===) for all values. @method static bool allNull(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is null for all values. @method static bool allNumeric(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is numeric for all values. @method static bool allObjectOrClass(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the value is an object, or a class that exists for all values. @method static bool allPhpVersion(string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert on PHP version for all values. @method static bool allPropertiesExist(mixed $value, array $properties, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the properties all exist for all values. @method static bool allPropertyExists(mixed $value, string $property, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the property exists for all values. @method static bool allRange(mixed $value, mixed $minValue, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that value is in range of numbers for all values. @method static bool allReadable(string $value, string|callable $message = null, string $propertyPath = null) Assert that the value is something readable for all values. @method static bool allRegex(mixed $value, string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value matches a regex for all values. @method static bool allSame(mixed $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are the same (using ===) for all values. @method static bool allSatisfy(mixed $value, callable $callback, string|callable $message = null, string $propertyPath = null) Assert that the provided value is valid according to a callback for all values. @method static bool allScalar(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a PHP scalar for all values. @method static bool allStartsWith(mixed $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string starts with a sequence of chars for all values. @method static bool allString(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is a string for all values. @method static bool allSubclassOf(mixed $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is subclass of given class-name for all values. @method static bool allTrue(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that the value is boolean True for all values. @method static bool allUrl(mixed $value, string|callable $message = null, string $propertyPath = null) Assert that value is an URL for all values. @method static bool allUuid(string $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid UUID for all values. @method static bool allVersion(string $version1, string $operator, string $version2, string|callable $message = null, string $propertyPath = null) Assert comparison of two versions for all values. @method static bool allWriteable(string $value, string|callable $message = null, string $propertyPath = null) Assert that the value is something writeable for all values. @method static bool nullOrAlnum(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is alphanumeric or that the value is null. @method static bool nullOrBase64(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that a constant is defined or that the value is null. @method static bool nullOrBetween(mixed|null $value, mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit or that the value is null. @method static bool nullOrBetweenExclusive(mixed|null $value, mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater than a lower limit, and less than an upper limit or that the value is null. @method static bool nullOrBetweenLength(mixed|null $value, int $minLength, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string length is between min and max lengths or that the value is null. @method static bool nullOrBoolean(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is php boolean or that the value is null. @method static bool nullOrChoice(mixed|null $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices or that the value is null. @method static bool nullOrChoicesNotEmpty(array|null $values, array $choices, string|callable $message = null, string $propertyPath = null) Determines if the values array has every choice as key and that this choice has content or that the value is null. @method static bool nullOrClassExists(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the class exists or that the value is null. @method static bool nullOrContains(mixed|null $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string contains a sequence of chars or that the value is null. @method static bool nullOrCount(array|Countable|ResourceBundle|SimpleXMLElement|null $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the count of countable is equal to count or that the value is null. @method static bool nullOrDate(string|null $value, string $format, string|callable $message = null, string $propertyPath = null) Assert that date is valid and corresponds to the given format or that the value is null. @method static bool nullOrDefined(mixed|null $constant, string|callable $message = null, string $propertyPath = null) Assert that a constant is defined or that the value is null. @method static bool nullOrDigit(mixed|null $value, string|callable $message = null, string $propertyPath = null) Validates if an integer or integerish is a digit or that the value is null. @method static bool nullOrDirectory(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that a directory exists or that the value is null. @method static bool nullOrE164(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid E164 Phone Number or that the value is null. @method static bool nullOrEmail(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL) or that the value is null. @method static bool nullOrEndsWith(mixed|null $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string ends with a sequence of chars or that the value is null. @method static bool nullOrEq(mixed|null $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are equal (using ==) or that the value is null. @method static bool nullOrEqArraySubset(mixed|null $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that the array contains the subset or that the value is null. @method static bool nullOrExtensionLoaded(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded or that the value is null. @method static bool nullOrExtensionVersion(string|null $extension, string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded and a specific version is installed or that the value is null. @method static bool nullOrFalse(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the value is boolean False or that the value is null. @method static bool nullOrFile(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that a file exists or that the value is null. @method static bool nullOrFloat(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php float or that the value is null. @method static bool nullOrGreaterOrEqualThan(mixed|null $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater or equal than given limit or that the value is null. @method static bool nullOrGreaterThan(mixed|null $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater than given limit or that the value is null. @method static bool nullOrImplementsInterface(mixed|null $class, string $interfaceName, string|callable $message = null, string $propertyPath = null) Assert that the class implements the interface or that the value is null. @method static bool nullOrInArray(mixed|null $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. This is an alias of Assertion\choice() or that the value is null. @method static bool nullOrInteger(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php integer or that the value is null. @method static bool nullOrIntegerish(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a php integer'ish or that the value is null. @method static bool nullOrInterfaceExists(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the interface exists or that the value is null. @method static bool nullOrIp(string|null $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 or IPv6 address or that the value is null. @method static bool nullOrIpv4(string|null $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 address or that the value is null. @method static bool nullOrIpv6(string|null $value, int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv6 address or that the value is null. @method static bool nullOrIsArray(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array or that the value is null. @method static bool nullOrIsArrayAccessible(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array or an array-accessible object or that the value is null. @method static bool nullOrIsCallable(mixed|null $value, string|callable $message = null, string $propertyPath = null) Determines that the provided value is callable or that the value is null. @method static bool nullOrIsCountable(array|Countable|ResourceBundle|SimpleXMLElement|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is countable or that the value is null. @method static bool nullOrIsInstanceOf(mixed|null $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is instance of given class-name or that the value is null. @method static bool nullOrIsJsonString(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid json string or that the value is null. @method static bool nullOrIsObject(mixed|null $value, string|callable $message = null, string $propertyPath = null) Determines that the provided value is an object or that the value is null. @method static bool nullOrIsResource(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a resource or that the value is null. @method static bool nullOrIsTraversable(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is an array or a traversable object or that the value is null. @method static bool nullOrKeyExists(mixed|null $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array or that the value is null. @method static bool nullOrKeyIsset(mixed|null $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object using isset() or that the value is null. @method static bool nullOrKeyNotExists(mixed|null $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key does not exist in an array or that the value is null. @method static bool nullOrLength(mixed|null $value, int $length, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string has a given length or that the value is null. @method static bool nullOrLessOrEqualThan(mixed|null $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less or equal than given limit or that the value is null. @method static bool nullOrLessThan(mixed|null $value, mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less than given limit or that the value is null. @method static bool nullOrMax(mixed|null $value, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that a number is smaller as a given limit or that the value is null. @method static bool nullOrMaxCount(array|Countable|ResourceBundle|SimpleXMLElement|null $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at most $count elements or that the value is null. @method static bool nullOrMaxLength(mixed|null $value, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string value is not longer than $maxLength chars or that the value is null. @method static bool nullOrMethodExists(string|null $value, mixed $object, string|callable $message = null, string $propertyPath = null) Determines that the named method is defined in the provided object or that the value is null. @method static bool nullOrMin(mixed|null $value, mixed $minValue, string|callable $message = null, string $propertyPath = null) Assert that a value is at least as big as a given limit or that the value is null. @method static bool nullOrMinCount(array|Countable|ResourceBundle|SimpleXMLElement|null $countable, int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at least $count elements or that the value is null. @method static bool nullOrMinLength(mixed|null $value, int $minLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that a string is at least $minLength chars long or that the value is null. @method static bool nullOrNoContent(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is empty or that the value is null. @method static bool nullOrNotBlank(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is not blank or that the value is null. @method static bool nullOrNotContains(mixed|null $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string does not contains a sequence of chars or that the value is null. @method static bool nullOrNotEmpty(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is not empty or that the value is null. @method static bool nullOrNotEmptyKey(mixed|null $value, string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object and its value is not empty or that the value is null. @method static bool nullOrNotEq(mixed|null $value1, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not equal (using ==) or that the value is null. @method static bool nullOrNotInArray(mixed|null $value, array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is not in array of choices or that the value is null. @method static bool nullOrNotIsInstanceOf(mixed|null $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is not instance of given class-name or that the value is null. @method static bool nullOrNotNull(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is not null or that the value is null. @method static bool nullOrNotRegex(mixed|null $value, string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value does not match a regex or that the value is null. @method static bool nullOrNotSame(mixed|null $value1, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not the same (using ===) or that the value is null. @method static bool nullOrNull(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is null or that the value is null. @method static bool nullOrNumeric(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is numeric or that the value is null. @method static bool nullOrObjectOrClass(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the value is an object, or a class that exists or that the value is null. @method static bool nullOrPhpVersion(string|null $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert on PHP version or that the value is null. @method static bool nullOrPropertiesExist(mixed|null $value, array $properties, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the properties all exist or that the value is null. @method static bool nullOrPropertyExists(mixed|null $value, string $property, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the property exists or that the value is null. @method static bool nullOrRange(mixed|null $value, mixed $minValue, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that value is in range of numbers or that the value is null. @method static bool nullOrReadable(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that the value is something readable or that the value is null. @method static bool nullOrRegex(mixed|null $value, string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value matches a regex or that the value is null. @method static bool nullOrSame(mixed|null $value, mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are the same (using ===) or that the value is null. @method static bool nullOrSatisfy(mixed|null $value, callable $callback, string|callable $message = null, string $propertyPath = null) Assert that the provided value is valid according to a callback or that the value is null. @method static bool nullOrScalar(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a PHP scalar or that the value is null. @method static bool nullOrStartsWith(mixed|null $string, string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string starts with a sequence of chars or that the value is null. @method static bool nullOrString(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is a string or that the value is null. @method static bool nullOrSubclassOf(mixed|null $value, string $className, string|callable $message = null, string $propertyPath = null) Assert that value is subclass of given class-name or that the value is null. @method static bool nullOrTrue(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that the value is boolean True or that the value is null. @method static bool nullOrUrl(mixed|null $value, string|callable $message = null, string $propertyPath = null) Assert that value is an URL or that the value is null. @method static bool nullOrUuid(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid UUID or that the value is null. @method static bool nullOrVersion(string|null $version1, string $operator, string $version2, string|callable $message = null, string $propertyPath = null) Assert comparison of two versions or that the value is null. @method static bool nullOrWriteable(string|null $value, string|callable $message = null, string $propertyPath = null) Assert that the value is something writeable or that the value is null.

Member Function Documentation

◆ __callStatic()

static Assert\Assertion::__callStatic ( $method,
$args )
static

static call handler to implement:

  • "null or assertion" delegation
  • "all" delegation.
Parameters
string$method
array$args
Return values
bool|mixed
Exceptions
AssertionFailedException

◆ alnum()

static Assert\Assertion::alnum ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is alphanumeric.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ base64()

static Assert\Assertion::base64 ( $value,
$message = null,
string $propertyPath = null )
static

Assert that a constant is defined.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ between()

static Assert\Assertion::between ( $value,
$lowerLimit,
$upperLimit,
$message = null,
string $propertyPath = null )
static

Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.

Parameters
mixed$value
mixed$lowerLimit
mixed$upperLimit
string | callable | null$message
string$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ betweenExclusive()

static Assert\Assertion::betweenExclusive ( $value,
$lowerLimit,
$upperLimit,
$message = null,
string $propertyPath = null )
static

Assert that a value is greater than a lower limit, and less than an upper limit.

Parameters
mixed$value
mixed$lowerLimit
mixed$upperLimit
string | callable | null$message
string$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ betweenLength()

static Assert\Assertion::betweenLength ( $value,
$minLength,
$maxLength,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string length is between min and max lengths.

Parameters
mixed$value
int$minLength
int$maxLength
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ boolean()

static Assert\Assertion::boolean ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is php boolean.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ choice()

static Assert\Assertion::choice ( $value,
array $choices,
$message = null,
string $propertyPath = null )
static

Assert that value is in array of choices.

Parameters
mixed$value
array$choices
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ choicesNotEmpty()

static Assert\Assertion::choicesNotEmpty ( array $values,
array $choices,
$message = null,
string $propertyPath = null )
static

Determines if the values array has every choice as key and that this choice has content.

Parameters
array$values
array$choices
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ classExists()

static Assert\Assertion::classExists ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the class exists.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ contains()

static Assert\Assertion::contains ( $string,
$needle,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string contains a sequence of chars.

Parameters
mixed$string
string$needle
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ count()

static Assert\Assertion::count ( $countable,
$count,
$message = null,
string $propertyPath = null )
static

Assert that the count of countable is equal to count.

Parameters
array | Countable | ResourceBundle | SimpleXMLElement$countable
int$count
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ createException()

static Assert\Assertion::createException ( $value,
$message,
$code,
string $propertyPath = null,
array $constraints = [] )
staticprotected

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.

Parameters
mixed$value
string | callable | null$message
int$code
string | null$propertyPath
array$constraints
Return values
mixed

◆ date()

static Assert\Assertion::date ( $value,
$format,
$message = null,
string $propertyPath = null )
static

Assert that date is valid and corresponds to the given format.

Parameters
string$value
string$formatsupports 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
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException
See also
http://php.net/manual/function.date.php#refsect1-function.date-parameters

◆ defined()

static Assert\Assertion::defined ( $constant,
$message = null,
string $propertyPath = null )
static

Assert that a constant is defined.

Parameters
mixed$constant
string | callable | null$message
string | null$propertyPath
Return values
bool

◆ digit()

static Assert\Assertion::digit ( $value,
$message = null,
string $propertyPath = null )
static

Validates if an integer or integerish is a digit.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ directory()

static Assert\Assertion::directory ( $value,
$message = null,
string $propertyPath = null )
static

Assert that a directory exists.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ e164()

static Assert\Assertion::e164 ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the given string is a valid E164 Phone Number.

See also
https://en.wikipedia.org/wiki/E.164
Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ email()

static Assert\Assertion::email ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL).

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ endsWith()

static Assert\Assertion::endsWith ( $string,
$needle,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string ends with a sequence of chars.

Parameters
mixed$string
string$needle
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ eq()

static Assert\Assertion::eq ( $value,
$value2,
$message = null,
string $propertyPath = null )
static

Assert that two values are equal (using ==).

Parameters
mixed$value
mixed$value2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ eqArraySubset()

static Assert\Assertion::eqArraySubset ( $value,
$value2,
$message = null,
string $propertyPath = null )
static

Assert that the array contains the subset.

Parameters
mixed$value
mixed$value2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ extensionLoaded()

static Assert\Assertion::extensionLoaded ( $value,
$message = null,
string $propertyPath = null )
static

Assert that extension is loaded.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ extensionVersion()

static Assert\Assertion::extensionVersion ( $extension,
$operator,
$version,
$message = null,
string $propertyPath = null )
static

Assert that extension is loaded and a specific version is installed.

Parameters
string$extension
string$operator
mixed$version
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ false()

static Assert\Assertion::false ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the value is boolean False.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ file()

static Assert\Assertion::file ( $value,
$message = null,
string $propertyPath = null )
static

Assert that a file exists.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ float()

static Assert\Assertion::float ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a php float.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ generateMessage()

static Assert\Assertion::generateMessage ( $message)
staticprotected

Generate the message.

Parameters
string | callable | null$message
Return values
string

◆ greaterOrEqualThan()

static Assert\Assertion::greaterOrEqualThan ( $value,
$limit,
$message = null,
string $propertyPath = null )
static

Determines if the value is greater or equal than given limit.

Parameters
mixed$value
mixed$limit
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ greaterThan()

static Assert\Assertion::greaterThan ( $value,
$limit,
$message = null,
string $propertyPath = null )
static

Determines if the value is greater than given limit.

Parameters
mixed$value
mixed$limit
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ implementsInterface()

static Assert\Assertion::implementsInterface ( $class,
$interfaceName,
$message = null,
string $propertyPath = null )
static

Assert that the class implements the interface.

Parameters
mixed$class
string$interfaceName
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ inArray()

static Assert\Assertion::inArray ( $value,
array $choices,
$message = null,
string $propertyPath = null )
static

Assert that value is in array of choices.

This is an alias of {

See also
choice()}.
Parameters
mixed$value
array$choices
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ integer()

static Assert\Assertion::integer ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a php integer.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ integerish()

static Assert\Assertion::integerish ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a php integer'ish.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ interfaceExists()

static Assert\Assertion::interfaceExists ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the interface exists.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ ip()

static Assert\Assertion::ip ( $value,
$flag = null,
$message = null,
string $propertyPath = null )
static

Assert that value is an IPv4 or IPv6 address (using input_filter/FILTER_VALIDATE_IP).

Parameters
string$value
int | null$flag
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException
See also
http://php.net/manual/filter.filters.flags.php

◆ ipv4()

static Assert\Assertion::ipv4 ( $value,
$flag = null,
$message = null,
string $propertyPath = null )
static

Assert that value is an IPv4 address (using input_filter/FILTER_VALIDATE_IP).

Parameters
string$value
int | null$flag
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException
See also
http://php.net/manual/filter.filters.flags.php

◆ ipv6()

static Assert\Assertion::ipv6 ( $value,
$flag = null,
$message = null,
string $propertyPath = null )
static

Assert that value is an IPv6 address (using input_filter/FILTER_VALIDATE_IP).

Parameters
string$value
int | null$flag
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException
See also
http://php.net/manual/filter.filters.flags.php

◆ isArray()

static Assert\Assertion::isArray ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is an array.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isArrayAccessible()

static Assert\Assertion::isArrayAccessible ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is an array or an array-accessible object.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isCallable()

static Assert\Assertion::isCallable ( $value,
$message = null,
string $propertyPath = null )
static

Determines that the provided value is callable.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isCountable()

static Assert\Assertion::isCountable ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is countable.

Parameters
array | Countable | ResourceBundle | SimpleXMLElement$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isInstanceOf()

static Assert\Assertion::isInstanceOf ( $value,
$className,
$message = null,
string $propertyPath = null )
static

Assert that value is instance of given class-name.

Parameters
mixed$value
string$className
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isJsonString()

static Assert\Assertion::isJsonString ( $value,
$message = null,
string $propertyPath = null )
static

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.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isObject()

static Assert\Assertion::isObject ( $value,
$message = null,
string $propertyPath = null )
static

Determines that the provided value is an object.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ isResource()

static Assert\Assertion::isResource ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a resource.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool

◆ isTraversable()

static Assert\Assertion::isTraversable ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is an array or a traversable object.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ keyExists()

static Assert\Assertion::keyExists ( $value,
$key,
$message = null,
string $propertyPath = null )
static

Assert that key exists in an array.

Parameters
mixed$value
string | int$key
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ keyIsset()

static Assert\Assertion::keyIsset ( $value,
$key,
$message = null,
string $propertyPath = null )
static

Assert that key exists in an array/array-accessible object using isset().

Parameters
mixed$value
string | int$key
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ keyNotExists()

static Assert\Assertion::keyNotExists ( $value,
$key,
$message = null,
string $propertyPath = null )
static

Assert that key does not exist in an array.

Parameters
mixed$value
string | int$key
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ length()

static Assert\Assertion::length ( $value,
$length,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string has a given length.

Parameters
mixed$value
int$length
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ lessOrEqualThan()

static Assert\Assertion::lessOrEqualThan ( $value,
$limit,
$message = null,
string $propertyPath = null )
static

Determines if the value is less or equal than given limit.

Parameters
mixed$value
mixed$limit
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ lessThan()

static Assert\Assertion::lessThan ( $value,
$limit,
$message = null,
string $propertyPath = null )
static

Determines if the value is less than given limit.

Parameters
mixed$value
mixed$limit
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ max()

static Assert\Assertion::max ( $value,
$maxValue,
$message = null,
string $propertyPath = null )
static

Assert that a number is smaller as a given limit.

Parameters
mixed$value
mixed$maxValue
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ maxCount()

static Assert\Assertion::maxCount ( $countable,
$count,
$message = null,
string $propertyPath = null )
static

Assert that the countable have at most $count elements.

Parameters
array | Countable | ResourceBundle | SimpleXMLElement$countable
int$count
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ maxLength()

static Assert\Assertion::maxLength ( $value,
$maxLength,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string value is not longer than $maxLength chars.

Parameters
mixed$value
int$maxLength
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ methodExists()

static Assert\Assertion::methodExists ( $value,
$object,
$message = null,
string $propertyPath = null )
static

Determines that the named method is defined in the provided object.

Parameters
string$value
mixed$object
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ min()

static Assert\Assertion::min ( $value,
$minValue,
$message = null,
string $propertyPath = null )
static

Assert that a value is at least as big as a given limit.

Parameters
mixed$value
mixed$minValue
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ minCount()

static Assert\Assertion::minCount ( $countable,
$count,
$message = null,
string $propertyPath = null )
static

Assert that the countable have at least $count elements.

Parameters
array | Countable | ResourceBundle | SimpleXMLElement$countable
int$count
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ minLength()

static Assert\Assertion::minLength ( $value,
$minLength,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that a string is at least $minLength chars long.

Parameters
mixed$value
int$minLength
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ noContent()

static Assert\Assertion::noContent ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is empty.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notBlank()

static Assert\Assertion::notBlank ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is not blank.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notContains()

static Assert\Assertion::notContains ( $string,
$needle,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string does not contains a sequence of chars.

Parameters
mixed$string
string$needle
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ notEmpty()

static Assert\Assertion::notEmpty ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is not empty.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notEmptyKey()

static Assert\Assertion::notEmptyKey ( $value,
$key,
$message = null,
string $propertyPath = null )
static

Assert that key exists in an array/array-accessible object and its value is not empty.

Parameters
mixed$value
string | int$key
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notEq()

static Assert\Assertion::notEq ( $value1,
$value2,
$message = null,
string $propertyPath = null )
static

Assert that two values are not equal (using ==).

Parameters
mixed$value1
mixed$value2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notInArray()

static Assert\Assertion::notInArray ( $value,
array $choices,
$message = null,
string $propertyPath = null )
static

Assert that value is not in array of choices.

Parameters
mixed$value
array$choices
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notIsInstanceOf()

static Assert\Assertion::notIsInstanceOf ( $value,
$className,
$message = null,
string $propertyPath = null )
static

Assert that value is not instance of given class-name.

Parameters
mixed$value
string$className
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notNull()

static Assert\Assertion::notNull ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is not null.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notRegex()

static Assert\Assertion::notRegex ( $value,
$pattern,
$message = null,
string $propertyPath = null )
static

Assert that value does not match a regex.

Parameters
mixed$value
string$pattern
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ notSame()

static Assert\Assertion::notSame ( $value1,
$value2,
$message = null,
string $propertyPath = null )
static

Assert that two values are not the same (using ===).

Parameters
mixed$value1
mixed$value2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ null()

static Assert\Assertion::null ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is null.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool

◆ numeric()

static Assert\Assertion::numeric ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is numeric.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ objectOrClass()

static Assert\Assertion::objectOrClass ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the value is an object, or a class that exists.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ phpVersion()

static Assert\Assertion::phpVersion ( $operator,
$version,
$message = null,
string $propertyPath = null )
static

Assert on PHP version.

Parameters
string$operator
mixed$version
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ propertiesExist()

static Assert\Assertion::propertiesExist ( $value,
array $properties,
$message = null,
string $propertyPath = null )
static

Assert that the value is an object or class, and that the properties all exist.

Parameters
mixed$value
array$properties
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ propertyExists()

static Assert\Assertion::propertyExists ( $value,
$property,
$message = null,
string $propertyPath = null )
static

Assert that the value is an object or class, and that the property exists.

Parameters
mixed$value
string$property
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ range()

static Assert\Assertion::range ( $value,
$minValue,
$maxValue,
$message = null,
string $propertyPath = null )
static

Assert that value is in range of numbers.

Parameters
mixed$value
mixed$minValue
mixed$maxValue
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ readable()

static Assert\Assertion::readable ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the value is something readable.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ regex()

static Assert\Assertion::regex ( $value,
$pattern,
$message = null,
string $propertyPath = null )
static

Assert that value matches a regex.

Parameters
mixed$value
string$pattern
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ same()

static Assert\Assertion::same ( $value,
$value2,
$message = null,
string $propertyPath = null )
static

Assert that two values are the same (using ===).

Parameters
mixed$value
mixed$value2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ satisfy()

static Assert\Assertion::satisfy ( $value,
$callback,
$message = null,
string $propertyPath = null )
static

Assert that the provided value is valid according to a callback.

If the callback returns false the assertion will fail.

Parameters
mixed$value
callable$callback
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ scalar()

static Assert\Assertion::scalar ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a PHP scalar.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ startsWith()

static Assert\Assertion::startsWith ( $string,
$needle,
$message = null,
string $propertyPath = null,
$encoding = 'utf8' )
static

Assert that string starts with a sequence of chars.

Parameters
mixed$string
string$needle
string | callable | null$message
string | null$propertyPath
string$encoding
Return values
bool
Exceptions
AssertionFailedException

◆ string()

static Assert\Assertion::string ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is a string.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ stringify()

static Assert\Assertion::stringify ( $value)
staticprotected

Make a string version of a value.

Parameters
mixed$value
Return values
string

◆ subclassOf()

static Assert\Assertion::subclassOf ( $value,
$className,
$message = null,
string $propertyPath = null )
static

Assert that value is subclass of given class-name.

Parameters
mixed$value
string$className
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ true()

static Assert\Assertion::true ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the value is boolean True.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ url()

static Assert\Assertion::url ( $value,
$message = null,
string $propertyPath = null )
static

Assert that value is an URL.

This code snipped was taken from the Symfony project and modified to the special demands of this method.

Parameters
mixed$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException
See also
https://github.com/symfony/Validator/blob/master/Constraints/UrlValidator.php
https://github.com/symfony/Validator/blob/master/Constraints/Url.php

◆ uuid()

static Assert\Assertion::uuid ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the given string is a valid UUID.

Uses code from that is MIT licensed.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ version()

static Assert\Assertion::version ( $version1,
$operator,
$version2,
$message = null,
string $propertyPath = null )
static

Assert comparison of two versions.

Parameters
string$version1
string$operator
string$version2
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

◆ writeable()

static Assert\Assertion::writeable ( $value,
$message = null,
string $propertyPath = null )
static

Assert that the value is something writeable.

Parameters
string$value
string | callable | null$message
string | null$propertyPath
Return values
bool
Exceptions
AssertionFailedException

The documentation for this class was generated from the following file: