ValidationUtility
Validation utility.
Table of Contents
- ensureBoolean() : mixed
- Ensure that the type of the given object is `boolean`.
- ensureInteger() : mixed
- Ensure that the type of the given object is `integer`.
- ensureNotNegative() : mixed
- Ensure that the given object is not less than 0.
- ensureNotNull() : mixed
- Ensure that the given object is not `null`.
- ensureNullOrArrayOfString() : mixed
- Ensure that the given object is null or an array of string.
- ensureNullOrArrayOfType() : mixed
- Ensure that the given object is null or an array whose elements are of the specified type.
- ensureNullOrString() : mixed
- Ensure that the given object is `null` or a `string` instance.
- ensureNullOrStringOrInteger() : mixed
- Ensure that the given object is `null`, a `string` instance, or an `integer` instance.
- ensureNullOrType() : mixed
- Ensure that the given object is `null` or an instance of the specified type.
- ensureString() : mixed
- Ensure that the type of the given object is `string`.
- ensureStringOrInteger() : mixed
- Ensure that the type of the given object is either `string` or `integer`.
Methods
ensureBoolean()
Ensure that the type of the given object is `boolean`.
public
static ensureBoolean(string $name, mixed $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : mixed
-
Value of a parameter.
Tags
Return values
mixed —ensureInteger()
Ensure that the type of the given object is `integer`.
public
static ensureInteger(string $name, mixed $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : mixed
-
Value of a parameter.
Tags
Return values
mixed —ensureNotNegative()
Ensure that the given object is not less than 0.
public
static ensureNotNegative(string $name, int $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : int
-
Value of a parameter.
Tags
Return values
mixed —ensureNotNull()
Ensure that the given object is not `null`.
public
static ensureNotNull(string $name, mixed $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : mixed
-
Value of a parameter.
Tags
Return values
mixed —ensureNullOrArrayOfString()
Ensure that the given object is null or an array of string.
public
static ensureNullOrArrayOfString(string $name[, array<string|int, mixed> &$array = null ]) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $array : array<string|int, mixed> = null
-
Value of a parameter.
Tags
Return values
mixed —ensureNullOrArrayOfType()
Ensure that the given object is null or an array whose elements are of the specified type.
public
static ensureNullOrArrayOfType(string $name[, array<string|int, mixed> &$array = null ], string $type) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $array : array<string|int, mixed> = null
-
Value of a parameter.
- $type : string
-
The expected type of the elements in the given array.
Tags
Return values
mixed —ensureNullOrString()
Ensure that the given object is `null` or a `string` instance.
public
static ensureNullOrString(string $name, int $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : int
-
Value of a parameter.
Tags
Return values
mixed —ensureNullOrStringOrInteger()
Ensure that the given object is `null`, a `string` instance, or an `integer` instance.
public
static ensureNullOrStringOrInteger(string $name, int $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : int
-
Value of a parameter.
Tags
Return values
mixed —ensureNullOrType()
Ensure that the given object is `null` or an instance of the specified type.
public
static ensureNullOrType(string $name, int $value, string $type) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : int
-
Value of a parameter.
- $type : string
-
The expected type of the value.
Tags
Return values
mixed —ensureString()
Ensure that the type of the given object is `string`.
public
static ensureString(string $name, mixed $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : mixed
-
Value of a parameter.
Tags
Return values
mixed —ensureStringOrInteger()
Ensure that the type of the given object is either `string` or `integer`.
public
static ensureStringOrInteger(string $name, int $value) : mixed
Parameters
- $name : string
-
Name of a parameter.
- $value : int
-
Value of a parameter.