\YaLinqoUtils

Functions for creating lambdas.

Summary

Methods
Properties
Constants
createLambda()
createComparer()
lambdaToSortFlagsAndOrder()
No public properties found
ERROR_CLOSURE_NULL
ERROR_CLOSURE_NOT_CALLABLE
ERROR_CANNOT_PARSE_LAMBDA
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

ERROR_CLOSURE_NULL

ERROR_CLOSURE_NULL

ERROR_CLOSURE_NOT_CALLABLE

ERROR_CLOSURE_NOT_CALLABLE

ERROR_CANNOT_PARSE_LAMBDA

ERROR_CANNOT_PARSE_LAMBDA

Methods

createLambda()

createLambda(callable|null  $closure, string  $closureArgs, \Closure|callable|null  $default = null) : callable|null

Convert string lambda to callable function. If callable is passed, return as is.

Parameters

callable|null $closure
string $closureArgs
\Closure|callable|null $default

Throws

\InvalidArgumentException

Both closure and default are null.

\InvalidArgumentException

Incorrect lambda syntax.

Returns

callable|null

createComparer()

createComparer(callable|integer|null  $closure, integer  $sortOrder, boolean  $isReversed) : callable|string|null

Convert string lambda or SORT_ flags to callable function. Sets isReversed to false if descending is reversed.

Parameters

callable|integer|null $closure
integer $sortOrder
boolean $isReversed

Throws

\InvalidArgumentException

Incorrect lambda syntax.

\InvalidArgumentException

Incorrect SORT_ flags.

Returns

callable|string|null

lambdaToSortFlagsAndOrder()

lambdaToSortFlagsAndOrder(callable|string|integer|null  $closure, integer|boolean  $sortOrder) : callable|string|integer|null

Convert string lambda to SORT_ flags. Convert sortOrder from bool to SORT_ order.

Parameters

callable|string|integer|null $closure
integer|boolean $sortOrder

Returns

callable|string|integer|null