Documentation

DataInterface
in

Table of Contents

Constants

MERGE  = 2
PRESERVE  = 0
REPLACE  = 1

Methods

append()  : void
Append a value to a key (assumes key refers to an array value)
export()  : array<string, mixed>
Export data as raw data
get()  : mixed
Get the raw value for a key
getData()  : DataInterface
Get a data instance for a key
has()  : bool
Check if the key exists
import()  : void
Import data into existing data
importData()  : void
Import data from an external data into existing data
remove()  : void
Remove a key
set()  : void
Set a value for a key

Constants

Methods

append()

Append a value to a key (assumes key refers to an array value)

public append(string $key[, mixed $value = null ]) : void

If the key does not yet exist it will be created. If the key references a non-array it's existing contents will be added into a new array before appending the new value.

Parameters
$key : string
$value : mixed = null
Tags
throws
InvalidPathException

if the given key is empty

export()

Export data as raw data

public export() : array<string, mixed>
Tags
psalm-mutation-free
Return values
array<string, mixed>

get()

Get the raw value for a key

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

If the key does not exist, an optional default value can be returned instead. If no default is provided then an exception will be thrown instead.

Parameters
$key : string
$default : mixed = null
Tags
throws
InvalidPathException

if the given key is empty

throws
InvalidPathException

if the given key does not exist and no default value was given

psalm-mutation-free

has()

Check if the key exists

public has(string $key) : bool
Parameters
$key : string
Tags
throws
InvalidPathException

if the given key is empty

psalm-mutation-free
Return values
bool

import()

Import data into existing data

public import(array<string, mixed> $data[, self::PRESERVE|self::REPLACE|self::MERGE $mode = self::REPLACE ]) : void
Parameters
$data : array<string, mixed>
$mode : self::PRESERVE|self::REPLACE|self::MERGE = self::REPLACE

importData()

Import data from an external data into existing data

public importData(DataInterface $data[, self::PRESERVE|self::REPLACE|self::MERGE $mode = self::REPLACE ]) : void
Parameters
$data : DataInterface
$mode : self::PRESERVE|self::REPLACE|self::MERGE = self::REPLACE

remove()

Remove a key

public remove(string $key) : void

No exception will be thrown if the key does not exist

Parameters
$key : string
Tags
throws
InvalidPathException

if the given key is empty

set()

Set a value for a key

public set(string $key[, mixed $value = null ]) : void

If the key does not yet exist it will be created.

Parameters
$key : string
$value : mixed = null
Tags
throws
InvalidPathException

if the given key is empty

throws
DataException

if the given key does not target an array


        
On this page

Search results