[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/beberlei/assert/lib/Assert/ -> Assertion.php (summary)

Assert LICENSE

File Size: 2797 lines (121 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Assertion:: (93 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()
  uniqueValues()
  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()


Class: Assertion  - X-Ref

Assert library.

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

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

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

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: string|callable|null $message

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

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

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: string|callable|null $message

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: string|callable|null $message

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

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

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

uniqueValues(array $values, $message = null, string $propertyPath = null)   X-Ref
Assert that values in array are unique (using strict equality).

param: mixed[] $values
param: string|callable|null $message

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

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

notBlank($value, $message = null, string $propertyPath = null)   X-Ref
Assert that value is not blank.

param: mixed $value
param: string|callable|null $message

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

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

directory($value, $message = null, string $propertyPath = null)   X-Ref
Assert that a directory exists.

param: string $value
param: string|callable|null $message

readable($value, $message = null, string $propertyPath = null)   X-Ref
Assert that the value is something readable.

param: string $value
param: string|callable|null $message

writeable($value, $message = null, string $propertyPath = null)   X-Ref
Assert that the value is something writeable.

param: string $value
param: string|callable|null $message

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

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

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

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

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

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

__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: string|callable|null $message

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

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

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

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

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

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

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

extensionLoaded($value, $message = null, string $propertyPath = null)   X-Ref
Assert that extension is loaded.

param: mixed $value
param: string|callable|null $message

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

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

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

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: string|callable|null $message

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

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

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

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

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

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

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

defined($constant, $message = null, string $propertyPath = null)   X-Ref
Assert that a constant is defined.

param: mixed $constant
param: string|callable|null $message

base64($value, $message = null, string $propertyPath = null)   X-Ref
Assert that a constant is defined.

param: string $value
param: string|callable|null $message

createException($value, $message, $code, $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
return: mixed

stringify($value)   X-Ref
Make a string version of a value.

param: mixed $value

generateMessage($message)   X-Ref
Generate the message.

param: string|callable|null $message



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer