class Structure implements JsonSerializable, ArrayAccess, IteratorAggregate, Countable (View source)

Structure class

Methods

__construct(mixed $data = null, string $format = Format::JSON)

Constructor

__clone()

Magic function to clone the structure object.

string
__toString()

Magic function to render this object as a string using default args of toString method.

mixed
jsonSerialize()

Implementation for the JsonSerializable interface.

def(string $path, mixed $value = '')

Sets a default value if not already assigned.

boolean
exists(string $path)

Check if a structure path exists.

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

Get a structure value.

reset()

Reset all data.

load(array|object $data, boolean $raw = false)

Load an array or object of values into the default namespace

loadFile(string $file, string $format = Format::JSON, array $options = array())

Load the contents of a file into the structure

loadString(string $data, string $format = Format::JSON, array $options = array())

Load a string into the structure

merge(Structure|mixed $source, boolean $raw = false)

Merge a structure data into this object.

mergeTo(string $path, Structure $source, boolean $raw = false)

Merge a structure data to a node.

extract(string $path)

extract

getRaw()

getRaw

boolean
offsetExists(mixed $offset)

Checks whether an offset exists in the iterator.

mixed
offsetGet(mixed $offset)

Gets an offset in the iterator.

void
offsetSet(mixed $offset, mixed $value)

Sets an offset in the iterator.

void
offsetUnset(mixed $offset)

Unsets an offset in the iterator.

set(string $path, mixed $value)

Set a structure value and convert object to array.

setRaw(string $path, mixed $value)

Set a structure value.

array
toArray()

Transforms a namespace to an array

object
toObject(string $class = 'stdClass')

Transforms a namespace to an object

string
toString(string $format = Format::JSON, mixed $options = array())

Get a namespace in a given string format

string[]
flatten(string $separator = '.')

Dump to on dimension array.

string
getSeparator()

Method to get property Separator

setSeparator(string $separator)

Method to set property separator

integer
push(string $path, mixed $value)

Push value to a path in structure

integer
unshift(string $path, mixed $value)

Prepend value to a path in structure.

mixed
shift(string $path)

To remove first element from the path of this structure.

mixed
pop(string $path)

To remove last element from the path of this structure.

getIterator()

Gets this object represented as an RecursiveArrayIterator.

integer
count()

Count elements of the data object

array
getIgnoreValues()

Method to get property IgnoreValues

setIgnoreValues(array $ignoreValues)

Method to set property ignoreValues

Details

at line line 53
__construct(mixed $data = null, string $format = Format::JSON)

Constructor

Parameters

mixed $data The data to bind to the new Structure object.
string $format The format of input, only work when first argument is string.

at line line 73
Structure __clone()

Magic function to clone the structure object.

Return Value

Structure

at line line 85
string __toString()

Magic function to render this object as a string using default args of toString method.

Return Value

string

at line line 106
mixed jsonSerialize()

Implementation for the JsonSerializable interface.

Allows us to pass Structure objects to json_encode.

Return Value

mixed

at line line 121
Structure def(string $path, mixed $value = '')

Sets a default value if not already assigned.

Parameters

string $path The name of the parameter.
mixed $value An optional value for the parameter.

Return Value

Structure Return self to support chaining.

at line line 138
boolean exists(string $path)

Check if a structure path exists.

Parameters

string $path Structure path (e.g. foo.content.showauthor)

Return Value

boolean

at line line 153
mixed get(string $path, mixed $default = null)

Get a structure value.

Parameters

string $path Structure path (e.g. foo.content.showauthor)
mixed $default Optional default value, returned if the internal value is null.

Return Value

mixed Value of entry or null

at line line 165
Structure reset()

Reset all data.

Return Value

Structure

at line line 180
Structure load(array|object $data, boolean $raw = false)

Load an array or object of values into the default namespace

Parameters

array|object $data The value to load into structure.
boolean $raw Set to false that we will convert all object to array.

Return Value

Structure Return this object to support chaining.

at line line 198
Structure loadFile(string $file, string $format = Format::JSON, array $options = array())

Load the contents of a file into the structure

Parameters

string $file Path to file to load
string $format Format of the file [optional: defaults to JSON]
array $options Options used by the formatter

Return Value

Structure Return this object to support chaining.

at line line 218
Structure loadString(string $data, string $format = Format::JSON, array $options = array())

Load a string into the structure

Parameters

string $data String to load into the structure
string $format Format of the string
array $options Options used by the formatter

Return Value

Structure Return this object to support chaining.

at line line 237
Structure merge(Structure|mixed $source, boolean $raw = false)

Merge a structure data into this object.

Parameters

Structure|mixed $source Source structure data to merge.
boolean $raw Set to false to convert all object to array.

Return Value

Structure Return this object to support chaining.

at line line 258
Structure mergeTo(string $path, Structure $source, boolean $raw = false)

Merge a structure data to a node.

Parameters

string $path The path to merge as root.
Structure $source Source structure data to merge.
boolean $raw Set to false to convert all object to array.

Return Value

Structure

at line line 292
Structure extract(string $path)

extract

Parameters

string $path

Return Value

Structure

at line line 302
stdClass getRaw()

getRaw

Return Value

stdClass

at line line 316
boolean offsetExists(mixed $offset)

Checks whether an offset exists in the iterator.

Parameters

mixed $offset The array offset.

Return Value

boolean True if the offset exists, false otherwise.

at line line 330
mixed offsetGet(mixed $offset)

Gets an offset in the iterator.

Parameters

mixed $offset The array offset.

Return Value

mixed The array value if it exists, null otherwise.

at line line 345
void offsetSet(mixed $offset, mixed $value)

Sets an offset in the iterator.

Parameters

mixed $offset The array offset.
mixed $value The array value.

Return Value

void

at line line 359
void offsetUnset(mixed $offset)

Unsets an offset in the iterator.

Parameters

mixed $offset The array offset.

Return Value

void

at line line 374
Structure set(string $path, mixed $value)

Set a structure value and convert object to array.

Parameters

string $path Structure Path (e.g. foo.content.showauthor)
mixed $value Value of entry.

Return Value

Structure Return self to support chaining.

at line line 396
Structure setRaw(string $path, mixed $value)

Set a structure value.

Parameters

string $path Structure Path (e.g. foo.content.showauthor)
mixed $value Value of entry.

Return Value

Structure Return self to support chaining.

at line line 410
array toArray()

Transforms a namespace to an array

Return Value

array An associative array holding the namespace data

at line line 424
object toObject(string $class = 'stdClass')

Transforms a namespace to an object

Parameters

string $class The class of object.

Return Value

object An an object holding the namespace data

at line line 439
string toString(string $format = Format::JSON, mixed $options = array())

Get a namespace in a given string format

Parameters

string $format Format to return the string in
mixed $options Parameters used by the formatter, see formatters for more info

Return Value

string Namespace in string format

at line line 524
string[] flatten(string $separator = '.')

Dump to on dimension array.

Parameters

string $separator The key separator.

Return Value

string[] Dumped array.

at line line 536
string getSeparator()

Method to get property Separator

Return Value

string

at line line 550
Structure setSeparator(string $separator)

Method to set property separator

Parameters

string $separator

Return Value

Structure Return self to support chaining.

at line line 567
integer push(string $path, mixed $value)

Push value to a path in structure

Parameters

string $path Parent structure Path (e.g. windwalker.content.showauthor)
mixed $value Value of entry, one or more elements.

Return Value

integer the new number of elements in the array.

at line line 613
integer unshift(string $path, mixed $value)

Prepend value to a path in structure.

Parameters

string $path Parent structure Path (e.g. windwalker.content.showauthor)
mixed $value Value of entry, one or more elements.

Return Value

integer the new number of elements in the array.

at line line 656
mixed shift(string $path)

To remove first element from the path of this structure.

Parameters

string $path The structure path.

Return Value

mixed The shifted value, or null if array is empty.

at line line 684
mixed pop(string $path)

To remove last element from the path of this structure.

Parameters

string $path The structure path.

Return Value

mixed The shifted value, or &null; if array is empty.

at line line 718
RecursiveArrayIterator getIterator()

Gets this object represented as an RecursiveArrayIterator.

This allows the data properties to be accessed via a foreach statement.

You can wrap this iterator by RecursiveIteratorIterator that will support recursive foreach. Example: foreach (new \RecursiveIteratorIterator($structure) as $value)

Return Value

RecursiveArrayIterator This object represented as an RecursiveArrayIterator.

See also

IteratorAggregate::getIterator()

at line line 731
integer count()

Count elements of the data object

Return Value

integer The custom count as an integer.

at line line 741
array getIgnoreValues()

Method to get property IgnoreValues

Return Value

array

at line line 753
Structure setIgnoreValues(array $ignoreValues)

Method to set property ignoreValues

Parameters

array $ignoreValues

Return Value

Structure Return self to support chaining.