Fr3nch13/CakePHP Utilities

ExtractTrait

Provides utility protected methods for extracting a property or column from an array or object.

Table of Contents

Methods

_createMatcherFilter()  : Closure
Returns a callable that receives a value and will return whether it matches certain condition.
_extract()  : mixed
Returns a column from $data that can be extracted by iterating over the column names contained in $path.
_propertyExtractor()  : callable
Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.
_simpleExtract()  : mixed
Returns a column from $data that can be extracted by iterating over the column names contained in $path

Methods

_createMatcherFilter()

Returns a callable that receives a value and will return whether it matches certain condition.

protected _createMatcherFilter(array<string|int, mixed> $conditions) : Closure
Parameters
$conditions : array<string|int, mixed>

A key-value list of conditions to match where the key is the property path to get from the current item and the value is the value to be compared the item with.

Return values
Closure

_extract()

Returns a column from $data that can be extracted by iterating over the column names contained in $path.

protected _extract(ArrayAccess|array<string|int, mixed> $data, array<string|int, string> $parts) : mixed

It will return arrays for elements in represented with {*}

Parameters
$data : ArrayAccess|array<string|int, mixed>

Data.

$parts : array<string|int, string>

Path to extract from.

_propertyExtractor()

Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.

protected _propertyExtractor(callable|string $path) : callable
Parameters
$path : callable|string

A dot separated path of column to follow so that the final one can be returned or a callable that will take care of doing that.

Return values
callable

_simpleExtract()

Returns a column from $data that can be extracted by iterating over the column names contained in $path

protected _simpleExtract(ArrayAccess|array<string|int, mixed> $data, array<string|int, string> $parts) : mixed
Parameters
$data : ArrayAccess|array<string|int, mixed>

Data.

$parts : array<string|int, string>

Path to extract from.


        
On this page

Search results