Skip to content

Latest commit

 

History

History
116 lines (77 loc) · 2.05 KB

AccessorStaticTrait.md

File metadata and controls

116 lines (77 loc) · 2.05 KB

AccessorStaticTrait Documentation

\Greg\Support\Accessor\AccessorStaticTrait is a private storage trait for static usage. You don't care anymore about setting a storage variable and creating base methods for using it.

Example:

class InMemory
{
    use \Greg\Support\Accessor\AccessorStaticTrait;

    public static function get($key)
    {
        return static::getFromAccessor($key);
    }

    public static function set($key, $value)
    {
        return static::setToAccessor($key, $value);
    }
}

Table of contents:

Methods:

getAccessor

Get storage.

&getAccessor(): array

setAccessor

Set storage.

setAccessor(array $accessor): array

$accessor - Storage.

inAccessor

Set storage.

inAccessor(string|array $key): boolean

$key - Could be a key or an array of keys.

getFromAccessor

Get values from storage.

getFromAccessor(string|array $key, string|array $else = null): mixed

$key - Could be a key or an array of keys;
$else - If values not found, will return this. Could be a key or an array of keys.

setToAccessor

Set a value to storage.

setToAccessor(string $key, mixed $value): array

$key - Key;
$value - Value.

addToAccessor

Add values to storage.

addToAccessor(array $values): array

$values - Values. Key-Value pair.

removeFromAccessor

Remove values from storage.

removeFromAccessor(string|array $key): array

$key - Could be a key or an array of keys.

resetAccessor

Cleanup storage.

resetAccessor(): array