class ArrayRepository

Traits

Properties

protected array<string, mixed> $data

The repository values.

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 $data = [])

Create an array repository.

array
all()

Retrieve all the items.

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

Retrieve a single item.

set(array $data)

Overwrite the entire repository.

merge(array ...$arrays)

Merge in other arrays.

add(string $key, mixed $value)

Add an item to the repository.

remove(string $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 25
__construct(array $data = [])

Create an array repository.

Parameters

array $data

at line 35
array all()

Retrieve all the items.

Return Value

array

at line 43
mixed get(string $key, mixed $default = null)

Retrieve a single item.

Parameters

string $key
mixed $default

Return Value

mixed

at line 54
ArrayRepository set(array $data)

Overwrite the entire repository.

Parameters

array $data

Return Value

ArrayRepository

at line 67
ArrayRepository merge(array ...$arrays)

Merge in other arrays.

Parameters

array ...$arrays

Return Value

ArrayRepository

at line 79
ArrayRepository add(string $key, mixed $value)

Add an item to the repository.

Parameters

string $key
mixed $value

Return Value

ArrayRepository

at line 91
ArrayRepository remove(string $key)

Remove an item from the repository.

Parameters

string $key

Return Value

ArrayRepository

at line 103
bool isEmpty()

Determine if the repository is empty.

Return Value

bool

at line 113
bool isNotEmpty()

Determine if the repository is not empty.

Return Value

bool