public
ICanBoogie\ErrorCollection
|
#
add( string $attribute, ICanBoogie\Error |string|boolean $error_or_format_or_true = true, array $args = [] )
Add an error associated with an attribute.
Add an error associated with an attribute.
Parameters
- $attribute
- Attribute name.
- $error_or_format_or_true
A ICanBoogie\Error instance or
a format to create that instance, or true .
- $args
Only used if $error_or_format_or_true is not a ICanBoogie\Error
instance or true .
Returns
|
public
ICanBoogie\ErrorCollection
|
#
add_generic( ICanBoogie\Error |string|boolean $error_or_format_or_true = true, array $args = [] )
Add an error not associated with any attribute.
Add an error not associated with any attribute.
Parameters
- $error_or_format_or_true
A ICanBoogie\Error instance or
a format to create that instance, or true .
- $args
Only used if $error_or_format_or_true is not a ICanBoogie\Error
instance or true .
Returns
|
protected
|
#
assert_valid_attribute( string $attribute )
Asserts that an attribute is valid.
Asserts that an attribute is valid.
Parameters
|
protected
|
#
assert_valid_error( mixed $error_or_format_or_true )
Asserts that the error type is valid.
Asserts that the error type is valid.
Parameters
|
protected
ICanBoogie\Error
|
|
public
|
#
offsetSet( string $attribute, ICanBoogie\Error |string|true $error )
Adds an error.
Parameters
See
Implementation of
ArrayAccess::offsetSet()
|
public
|
#
offsetUnset( string|null $attribute )
Clears the errors of an attribute.
Clears the errors of an attribute.
Parameters
- $attribute
- Attribute name or
null for generic.
Implementation of
ArrayAccess::offsetUnset()
|
public
boolean
|
#
offsetExists( string|null $attribute )
Checks if an error is defined for an attribute.
Checks if an error is defined for an attribute.
<?php
use ICanBoogie\ErrorCollection
$errors = new ErrorCollection;
isset($errors['username']);
$errors->add('username');
isset($errors['username']);
Parameters
- $attribute
- Attribute name or
null for generic.
Returns
boolean true if an error is defined for the specified attribute, false otherwise.
Implementation of
ArrayAccess::offsetExists()
|
public
ICanBoogie\Error[]
|
#
offsetGet( string|null $attribute )
Returns errors associated with an attribute.
Returns errors associated with an attribute.
<?php
use ICanBoogie\ErrorCollection;
$errors = new ErrorCollection;
$errors['password']
$errors->add('password')
Parameters
- $attribute
- Attribute name or
null for generic.
Returns
Implementation of
ArrayAccess::offsetGet()
|
public
ICanBoogie\ErrorCollection
|
|
public
|
|
public
|
#
getIterator( )
Inheritdoc
Implementation of
IteratorAggregate::getIterator()
|
public
|
#
each( callable $callback )
Iterates through errors using a callback.
Iterates through errors using a callback.
```php
<?php
use ICanBoogie\ErrorCollection;
$errors = new ErrorCollection;
$errors->add('username', "Funny user name");
$errors->add('password', "Weak password");
$errors->each(function ($error, $attribute, $errors) {
echo "$attribute => $error<br />";
});
Parameters
- $callback
Function to execute for each element, taking three arguments:
Error $error : The current error.
string $attribute : The attribute or self::GENERIC.
ErrorCollection $collection : This instance.
|
public
|
#
count( )
Returns the total number of errors.
Returns the total number of errors.
Inheritdoc
Implementation of
Countable::count()
|
public
|
#
jsonSerialize( )
Inheritdoc
Implementation of
JsonSerializable::jsonSerialize()
|
public
Error[][]
|
#
to_array( )
Converts the object into an array.
Converts the object into an array.
Returns
Error[][]
|