openmediavault  4.0 (Arrakis)
The open network attached storage solution
Public Member Functions | Protected Member Functions | List of all members
OMV\Dictionary Class Reference

Public Member Functions

 __construct (array $data=[])
 
 exists ($key)
 
 assertExists ($key)
 
 getData ()
 
 get ($key, $default=NULL)
 
 set ($key, $value)
 
 copy ($srcKey, $destKey)
 
 remove ($key)
 
 toJson ()
 
 fromJson ($json="")
 

Protected Member Functions

 isValidKey ($key)
 
 assertValidKey ($key)
 

Detailed Description

Represents a collection of keys and values.

Constructor & Destructor Documentation

◆ __construct()

OMV\Dictionary::__construct ( array  $data = [])

Constructor.

Parameters
dataThe associative array containing the data.

Member Function Documentation

◆ assertExists()

OMV\Dictionary::assertExists (   $key)

Assert that the specified key exists.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
Returns
None.
Exceptions

◆ assertValidKey()

OMV\Dictionary::assertValidKey (   $key)
protected

Assert that the given key is valid.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
Returns
None.
Exceptions

◆ copy()

OMV\Dictionary::copy (   $srcKey,
  $destKey 
)

Copy a key.

Parameters
srcKeyThe source key in dot notation, e.g. 'a.b.c'.
destKeyThe destination key in dot notation, e.g. 'a.b.c'.
Returns
None.

◆ exists()

OMV\Dictionary::exists (   $key)

Check whether the specified key exists.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
Returns
Returns TRUE if the key exists, otherwise FALSE.

◆ fromJson()

OMV\Dictionary::fromJson (   $json = "")

Import JSON data.

Parameters
jsonThe JSON string.
Returns
None.

◆ get()

OMV\Dictionary::get (   $key,
  $default = NULL 
)

Get the value for a key.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
defaultThe optional default value.
Returns
The requested value.

◆ getData()

OMV\Dictionary::getData ( )

Get the whole data.

Returns
The whole data.

◆ isValidKey()

OMV\Dictionary::isValidKey (   $key)
protected

Check whether the given key is valid.

Parameters
keyThe key in dot notation, e.g. 'a.b.c' or 'a.b.0.c.1'
Returns
Returns TRUE if the key is valid, otherwise FALSE.

◆ remove()

OMV\Dictionary::remove (   $key)

Remove a key.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
Returns
None.

◆ set()

OMV\Dictionary::set (   $key,
  $value 
)

Set a value for a key.

Parameters
keyThe key in dot notation, e.g. 'a.b.c'.
valueThe value of the given key.
Returns
None.

◆ toJson()

OMV\Dictionary::toJson ( )

Convert the data to JSON.

Returns
JSON serialized data.

The documentation for this class was generated from the following file: