class Result implements Stringable, Traversable, Countable, ArrayAccess, IteratorAggregate (View source)

Result class.

Properties

protected $attributes

Methods

__construct(mixed $value, bool $result, array $validations, array $errors, array $metadata)

Result constructor.

string
__toString()

Returns error messages.

addAttribute(string $name, mixed $value)

Adds an attribute to the result object.

int
count()

Countable::count() interface implementation.

static Result
from(array $data)

Result factory method.

mixed
getAttribute(string $name, mixed $default = null)

Returns a property or an attribute from the result object.

array
getAttributes()

Returns the attributes (any additional variables) of the result object.

array
getErrors()

Returns the errors of the result object.

getIterator()

IteratorAggregate::getIterator() interface implementation.

array
getMetadata()

Returns the metadata of the result object.

bool
getResult()

Returns the final result of the result object.

array
getValidations()

Returns the validations of the result object.

mixed
getValue()

Returns the value of the result object.

bool
offsetExists(mixed $offset)

ArrayAccess::offsetExists() interface implementation.

mixed
offsetGet(mixed $offset)

ArrayAccess::offsetGet() interface implementation.

void
offsetSet(mixed $offset, mixed $value)

ArrayAccess::offsetSet() interface implementation.

void
offsetUnset(mixed $offset)

ArrayAccess::offsetUnset() interface implementation.

removeAttribute(string $name)

Removes an attribute from the result object.

array
toArray()

Returns the result object as an array including the attributes.

string
toString()

Returns the result object as a string (formatted error message or an empty string if there wasn't any errors).

Details

__construct(mixed $value, bool $result, array $validations, array $errors, array $metadata)

Result constructor.

Parameters

mixed $value
bool $result
array $validations
array $errors
array $metadata

string __toString()

Returns error messages.

Return Value

string

Result addAttribute(string $name, mixed $value)

Adds an attribute to the result object.

Parameters

string $name
mixed $value

Return Value

Result

int count()

Countable::count() interface implementation.

{@inheritDoc}

Return Value

int

static Result from(array $data)

Result factory method.

Parameters

array $data

Result data. See self::__construct() for the expected data-types.

Return Value

Result

mixed getAttribute(string $name, mixed $default = null)

Returns a property or an attribute from the result object.

Parameters

string $name
mixed $default

Return Value

mixed

array getAttributes()

Returns the attributes (any additional variables) of the result object.

Return Value

array

array getErrors()

Returns the errors of the result object.

Return Value

array

Traversable getIterator()

IteratorAggregate::getIterator() interface implementation.

Return Value

Traversable

array getMetadata()

Returns the metadata of the result object.

Return Value

array

bool getResult()

Returns the final result of the result object.

Return Value

bool

array getValidations()

Returns the validations of the result object.

Return Value

array

mixed getValue()

Returns the value of the result object.

Return Value

mixed

bool offsetExists(mixed $offset)

ArrayAccess::offsetExists() interface implementation.

{@inheritDoc}

Parameters

mixed $offset

Return Value

bool

mixed offsetGet(mixed $offset)

ArrayAccess::offsetGet() interface implementation.

{@inheritDoc}

Parameters

mixed $offset

Return Value

mixed

void offsetSet(mixed $offset, mixed $value)

ArrayAccess::offsetSet() interface implementation.

{@inheritDoc}

Parameters

mixed $offset
mixed $value

Return Value

void

void offsetUnset(mixed $offset)

ArrayAccess::offsetUnset() interface implementation.

{@inheritDoc}

Parameters

mixed $offset

Return Value

void

Result removeAttribute(string $name)

Removes an attribute from the result object.

Parameters

string $name

Return Value

Result

array toArray()

Returns the result object as an array including the attributes.

Return Value

array

string toString()

Returns the result object as a string (formatted error message or an empty string if there wasn't any errors).

Return Value

string