Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
JmesPath\Utils Class Reference

Static Public Member Functions

static add ($a, $b)
 Safely add together two values.
 
static isArray ($value)
 Determine if the provided value is a JMESPath compatible array.
 
static isEqual ($a, $b)
 JSON aware value comparison function.
 
static isObject ($value)
 Determine if the provided value is a JMESPath compatible object.
 
static isTruthy ($value)
 
static slice ($value, $start=null, $stop=null, $step=1)
 Creates a Python-style slice of a string or array.
 
static stableSort (array $data, callable $sortFn)
 JMESPath requires a stable sorting algorithm, so here we'll implement a simple Schwartzian transform that uses array index positions as tie breakers.
 
static type ($arg)
 Gets the JMESPath type equivalent of a PHP variable.
 

Static Public Attributes

static $typeMap
 

Member Function Documentation

◆ add()

static JmesPath\Utils::add ( $a,
$b )
static

Safely add together two values.

Parameters
mixed$aFirst value to add
mixed$bSecond value to add
Return values
int|float

◆ isArray()

static JmesPath\Utils::isArray ( $value)
static

Determine if the provided value is a JMESPath compatible array.

Parameters
mixed$value
Return values
bool

◆ isEqual()

static JmesPath\Utils::isEqual ( $a,
$b )
static

JSON aware value comparison function.

Parameters
mixed$aFirst value to compare
mixed$bSecond value to compare
Return values
bool

◆ isObject()

static JmesPath\Utils::isObject ( $value)
static

Determine if the provided value is a JMESPath compatible object.

Parameters
mixed$value
Return values
bool

◆ slice()

static JmesPath\Utils::slice ( $value,
$start = null,
$stop = null,
$step = 1 )
static

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

Parameters
array | string$valueValue to slice
int | null$startStarting position
int | null$stopStop position
int$stepStep (1, 2, -1, -2, etc.)
Return values
array|string
Exceptions
InvalidArgumentException

◆ stableSort()

static JmesPath\Utils::stableSort ( array $data,
callable $sortFn )
static

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$dataList or map of data to sort
callable$sortFnCallable used to sort values
Return values
arrayReturns the sorted array @externalurl http://en.wikipedia.org/wiki/Schwartzian_transform

◆ type()

static JmesPath\Utils::type ( $arg)
static

Gets the JMESPath type equivalent of a PHP variable.

Parameters
mixed$argPHP variable
Return values
stringReturns the JSON data type
Exceptions
InvalidArgumentExceptionwhen an unknown type is given.

Member Data Documentation

◆ $typeMap

JmesPath\Utils::$typeMap
static
Initial value:
= [
'boolean' => 'boolean',
'string' => 'string',
'NULL' => 'null',
'double' => 'number',
'float' => 'number',
'integer' => 'number'
]

The documentation for this class was generated from the following file: