Env
in package
Provides a simple environment based search.
The runtime utilized by the Env class can be customized via environment variables. If the JP_PHP_COMPILE environment variable is specified, then the CompilerRuntime will be utilized. If set to "on", JMESPath expressions will be cached to the system's temp directory. Set the environment variable to a string to cache expressions to a specific directory.
Table of Contents
- COMPILE_DIR = 'JP_PHP_COMPILE'
- cleanCompileDir() : int
- Delete all previously compiled JMESPath files from the JP_COMPILE_DIR directory or sys_get_temp_dir().
- createRuntime() : callable
- Creates a JMESPath runtime based on environment variables and extensions available on a system.
- search() : mixed
- Returns data from the input array that matches a JMESPath expression.
- getEnvVariable() : string|null
- Reads an environment variable from $_SERVER, $_ENV or via getenv().
Constants
COMPILE_DIR
public
mixed
COMPILE_DIR
= 'JP_PHP_COMPILE'
Methods
cleanCompileDir()
Delete all previously compiled JMESPath files from the JP_COMPILE_DIR directory or sys_get_temp_dir().
public
static cleanCompileDir() : int
Return values
int —Returns the number of deleted files.
createRuntime()
Creates a JMESPath runtime based on environment variables and extensions available on a system.
public
static createRuntime() : callable
Return values
callable —search()
Returns data from the input array that matches a JMESPath expression.
public
static search(string $expression, mixed $data) : mixed
Parameters
- $expression : string
-
JMESPath expression to evaluate
- $data : mixed
-
JSON-like data to search
Return values
mixed —Returns the matching data or null
getEnvVariable()
Reads an environment variable from $_SERVER, $_ENV or via getenv().
private
static getEnvVariable(string $name) : string|null
Parameters
- $name : string