\JmesPathUtils

Summary

Methods
Properties
Constants
isTruthy()
type()
isObject()
isArray()
isEqual()
add()
stableSort()
slice()
$typeMap
No constants found
No protected methods found
No protected properties found
N/A
adjustEndpoint()
adjustSlice()
sliceIndices()
No private properties found
N/A

Properties

$typeMap

$typeMap

Methods

isTruthy()

isTruthy(mixed  $value) : bool

Returns true if the value is truthy

Parameters

mixed $value

Value to check

Returns

bool —

type()

type(mixed  $arg) : string

Gets the JMESPath type equivalent of a PHP variable.

Parameters

mixed $arg

PHP variable

Throws

\InvalidArgumentException

when an unknown type is given.

Returns

string —

Returns the JSON data type

isObject()

isObject(mixed  $value) : bool

Determine if the provided value is a JMESPath compatible object.

Parameters

mixed $value

Returns

bool —

isArray()

isArray(mixed  $value) : bool

Determine if the provided value is a JMESPath compatible array.

Parameters

mixed $value

Returns

bool —

isEqual()

isEqual(mixed  $a, mixed  $b) : bool

JSON aware value comparison function.

Parameters

mixed $a

First value to compare

mixed $b

Second value to compare

Returns

bool —

add()

add(mixed  $a, mixed  $b) : int|float

Safely add together two values.

Parameters

mixed $a

First value to add

mixed $b

Second value to add

Returns

int|float —

stableSort()

stableSort(array  $data, callable  $sortFn) : array

JMESPath requires a stable sorting algorithm, so here we'll implement a simple Schwartzian transform that uses array index positions as tie breakers.

Parameters

array $data

List or map of data to sort

callable $sortFn

Callable used to sort values

Returns

array —

Returns the sorted array

slice()

slice(array|string  $value, int|null  $start = null, int|null  $stop = null, int  $step = 1) : array|string

Creates a Python-style slice of a string or array.

Parameters

array|string $value

Value to slice

int|null $start

Starting position

int|null $stop

Stop position

int $step

Step (1, 2, -1, -2, etc.)

Throws

\InvalidArgumentException

Returns

array|string —

adjustEndpoint()

adjustEndpoint(mixed  $length, mixed  $endpoint, mixed  $step) : mixed

Parameters

mixed $length
mixed $endpoint
mixed $step

Returns

mixed —

adjustSlice()

adjustSlice(mixed  $length, mixed  $start, mixed  $stop, mixed  $step) : mixed

Parameters

mixed $length
mixed $start
mixed $stop
mixed $step

Returns

mixed —

sliceIndices()

sliceIndices(mixed  $subject, mixed  $start, mixed  $stop, mixed  $step) : mixed

Parameters

mixed $subject
mixed $start
mixed $stop
mixed $step

Returns

mixed —