abstract class ArrayBodyRepository implements BodyRepository, MergeableBody

Traits

Properties

protected array<array-key, mixed> $data

The repository data.

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

__construct(array $value = [])

Create an array body repository.

set(mixed $value)

Set the repository value.

merge(array ...$arrays)

Merge arrays into the repository.

add(string|int|null $key = null, mixed $value = null)

Add an element to the repository.

mixed
all()

Get the raw data in the repository.

mixed
get(string|int|null $key = null, mixed $default = null)

Get a value from the repository.

remove(string|int $key)

Remove an item from the repository.

bool
isEmpty()

Determine if the repository is empty.

bool
isNotEmpty()

Determine if the repository is not empty.

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

at line 28
__construct(array $value = [])

Create an array body repository.

Parameters

array $value

at line 39
BodyRepository set(mixed $value)

Set the repository value.

Parameters

mixed $value

Return Value

BodyRepository

at line 56
MergeableBody merge(array ...$arrays)

Merge arrays into the repository.

Parameters

array ...$arrays

Return Value

MergeableBody

at line 69
ArrayBodyRepository add(string|int|null $key = null, mixed $value = null)

Add an element to the repository.

Parameters

string|int|null $key
mixed $value

Return Value

ArrayBodyRepository

at line 83
mixed all()

Get the raw data in the repository.

Return Value

mixed

at line 96
mixed get(string|int|null $key = null, mixed $default = null)

Get a value from the repository.

Alias of all().

Parameters

string|int|null $key
mixed $default

Return Value

mixed

at line 111
ArrayBodyRepository remove(string|int $key)

Remove an item from the repository.

Parameters

string|int $key

Return Value

ArrayBodyRepository

at line 123
bool isEmpty()

Determine if the repository is empty.

Return Value

bool

at line 133
bool isNotEmpty()

Determine if the repository is not empty.

Return Value

bool