Documentation

Utils
in package

Table of Contents

$typeMap  : mixed
add()  : int|float
Safely add together two values.
isArray()  : bool
Determine if the provided value is a JMESPath compatible array.
isEqual()  : bool
JSON aware value comparison function.
isObject()  : bool
Determine if the provided value is a JMESPath compatible object.
isTruthy()  : bool
Returns true if the value is truthy
slice()  : array<string|int, mixed>|string
Creates a Python-style slice of a string or array.
stableSort()  : array<string|int, mixed>
JMESPath requires a stable sorting algorithm, so here we'll implement a simple Schwartzian transform that uses array index positions as tie breakers.
type()  : string
Gets the JMESPath type equivalent of a PHP variable.
adjustEndpoint()  : mixed
adjustSlice()  : mixed
sliceIndices()  : mixed

Properties

$typeMap

public static mixed $typeMap = ['boolean' => 'boolean', 'string' => 'string', 'NULL' => 'null', 'double' => 'number', 'float' => 'number', 'integer' => 'number']

Methods

add()

Safely add together two values.

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

First value to add

$b : mixed

Second value to add

Return values
int|float

isArray()

Determine if the provided value is a JMESPath compatible array.

public static isArray(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isEqual()

JSON aware value comparison function.

public static isEqual(mixed $a, mixed $b) : bool
Parameters
$a : mixed

First value to compare

$b : mixed

Second value to compare

Return values
bool

isObject()

Determine if the provided value is a JMESPath compatible object.

public static isObject(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isTruthy()

Returns true if the value is truthy

public static isTruthy(mixed $value) : bool
Parameters
$value : mixed

Value to check

Return values
bool

slice()

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

public static slice(array<string|int, mixed>|string $value[, int|null $start = null ][, int|null $stop = null ][, int $step = 1 ]) : array<string|int, mixed>|string
Parameters
$value : array<string|int, mixed>|string

Value to slice

$start : int|null = null

Starting position

$stop : int|null = null

Stop position

$step : int = 1

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

Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>|string

stableSort()

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

public static stableSort(array<string|int, mixed> $data, callable $sortFn) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

List or map of data to sort

$sortFn : callable

Callable used to sort values

Tags
link
http://en.wikipedia.org/wiki/Schwartzian_transform
Return values
array<string|int, mixed>

Returns the sorted array

type()

Gets the JMESPath type equivalent of a PHP variable.

public static type(mixed $arg) : string
Parameters
$arg : mixed

PHP variable

Tags
throws
InvalidArgumentException

when an unknown type is given.

Return values
string

Returns the JSON data type

adjustEndpoint()

private static adjustEndpoint(mixed $length, mixed $endpoint, mixed $step) : mixed
Parameters
$length : mixed
$endpoint : mixed
$step : mixed
Return values
mixed

adjustSlice()

private static adjustSlice(mixed $length, mixed $start, mixed $stop, mixed $step) : mixed
Parameters
$length : mixed
$start : mixed
$stop : mixed
$step : mixed
Return values
mixed

sliceIndices()

private static sliceIndices(mixed $subject, mixed $start, mixed $stop, mixed $step) : mixed
Parameters
$subject : mixed
$start : mixed
$stop : mixed
$step : mixed
Return values
mixed

Search results