VELOX API Docs

Data
in package

A class that serves as an abstracted data bag/store that is accessible via dot-notation.

Example:

// get all data
$allData = Data::getAll();

// check for variable availability
$someVarExists = Data::has('someVar');

// get a specific variable or fall back to a default value
$someVar = Data::get('someVar', 'fallbackValue');

// set a specific variable value
Data::set('someNewVar.someKey', 'someValue');
Tags
since
1.0.0

Table of Contents

ON_LOAD  = 'data.on.load'
This event will be dispatched when the data is loaded.
$bag  : array<string|int, mixed>
The currently loaded data.
get()  : mixed
Gets a value of a key from `self::$bag` via dot-notation.
getAll()  : array<string|int, mixed>
Returns the currently loaded data.
has()  : bool
Checks whether a value of a key exists in `self::$bag` via dot-notation.
set()  : void
Sets a value of a key in `self::$bag` via dot-notation.
load()  : void
Loads the data from system configuration.

Constants

ON_LOAD

This event will be dispatched when the data is loaded.

public string ON_LOAD = 'data.on.load'

This event will be passed a reference to the data array.

Properties

$bag

The currently loaded data.

protected static array<string|int, mixed> $bag = []

Methods

get()

Gets a value of a key from `self::$bag` via dot-notation.

public static get(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string

The dotted key representation.

$default : mixed = null

[optional] The default fallback value.

Return values
mixed

The requested value or null.

getAll()

Returns the currently loaded data.

public static getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

has()

Checks whether a value of a key exists in `self::$bag` via dot-notation.

public static has(string $key) : bool
Parameters
$key : string

The dotted key representation.

Return values
bool

set()

Sets a value of a key in `self::$bag` via dot-notation.

public static set(string $key, mixed $value) : void
Parameters
$key : string

The dotted key representation.

$value : mixed

The value to set.

Return values
void

load()

Loads the data from system configuration.

protected static load() : void
Return values
void

Search results