\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 : 

Type

Methods

isTruthy()

isTruthy(mixed  $value) : boolean

Returns true if the value is truthy

Parameters

mixed $value

Value to check

Returns

boolean

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) : boolean

Determine if the provided value is a JMESPath compatible object.

Parameters

mixed $value

Returns

boolean

isArray()

isArray(mixed  $value) : boolean

Determine if the provided value is a JMESPath compatible array.

Parameters

mixed $value

Returns

boolean

isEqual()

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

JSON aware value comparison function.

Parameters

mixed $a

First value to compare

mixed $b

Second value to compare

Returns

boolean

add()

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

Safely add together two values.

Parameters

mixed $a

First value to add

mixed $b

Second value to add

Returns

integer|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, integer|null  $start = null, integer|null  $stop = null, integer  $step = 1) : array|string

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

Parameters

array|string $value

Value to slice

integer|null $start

Starting position

integer|null $stop

Stop position

integer $step

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

Throws

\InvalidArgumentException

Returns

array|string

adjustEndpoint()

adjustEndpoint(  $length,   $endpoint,   $step) 

Parameters

$length
$endpoint
$step

adjustSlice()

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

Parameters

$length
$start
$stop
$step

sliceIndices()

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

Parameters

$subject
$start
$stop
$step