class ArraySubset extends Constraint (View source)

Properties

protected iterable $subset
protected bool $strict

Methods

void
__construct(iterable $subset, bool $strict = false)

Create a new array subset constraint instance.

bool|null
evaluate(mixed $other, string $description = '', bool $returnResult = false)

Evaluates the constraint for parameter $other.

string
toString()

Returns a string representation of the constraint.

string
failureDescription(mixed $other)

Returns the description of the failure.

array
toArray(iterable $other)

Returns the description of the failure.

Details

void __construct(iterable $subset, bool $strict = false)

Create a new array subset constraint instance.

Parameters

iterable $subset
bool $strict

Return Value

void

bool|null evaluate(mixed $other, string $description = '', bool $returnResult = false)

Evaluates the constraint for parameter $other.

If $returnResult is set to false (the default), an exception is thrown in case of a failure. null is returned otherwise.

If $returnResult is true, the result of the evaluation is returned as a boolean value instead: true in case of success, false in case of a failure.

Parameters

mixed $other
string $description
bool $returnResult

Return Value

bool|null

Exceptions

ExpectationFailedException
InvalidArgumentException

string toString()

Returns a string representation of the constraint.

Return Value

string

Exceptions

InvalidArgumentException

protected string failureDescription(mixed $other)

Returns the description of the failure.

The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second part of that sentence.

Parameters

mixed $other

Return Value

string

Exceptions

InvalidArgumentException

protected array toArray(iterable $other)

Returns the description of the failure.

The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second part of that sentence.

Parameters

iterable $other

Return Value

array

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.