PHP Class Parkour\Access

显示文件 Open project: benjamminf/craft-embedded-assets Class Usage Examples

Public Methods

Method Description
get ( array $data, array | string $path, mixed $default = null ) : mixed Returns the value at the given path.
has ( array $data, array | string $path ) : boolean Tells if there is data at the given path.
set ( array $data, array | string $path, mixed $value ) : mixed Sets data at the given path.
splitPath ( array | string $path ) : array Splits a path into multiple keys.
update ( array $data, array | string $path, callable $cb ) : mixed Updates data at the given path.

Method Details

get() public static method

Returns the value at the given path.
See also: splitPath()
public static get ( array $data, array | string $path, mixed $default = null ) : mixed
$data array Data.
$path array | string Path.
$default mixed Default value.
return mixed Value.

has() public static method

Tells if there is data at the given path.
See also: splitPath()
public static has ( array $data, array | string $path ) : boolean
$data array Data.
$path array | string Path.
return boolean If there is data.

set() public static method

Sets data at the given path.
See also: splitPath()
public static set ( array $data, array | string $path, mixed $value ) : mixed
$data array Data.
$path array | string Path.
$value mixed Value.
return mixed Updated data.

splitPath() public static method

Splits a path into multiple keys.
public static splitPath ( array | string $path ) : array
$path array | string Path.
return array Keys.

update() public static method

Updates data at the given path.
See also: splitPath()
public static update ( array $data, array | string $path, callable $cb ) : mixed
$data array Data.
$path array | string Path.
$cb callable Callback to update the value.
return mixed Updated data.