Oihana PHP Arango

FilterFunction uses ConstantsTrait

Table of Contents

Constants

ABS  : string = 'abs'
ACOS  : string = 'acos'
APPEND  : string = 'append'
ASIN  : string = 'asin'
ATAN  : string = 'atan'
ATAN2  : string = 'atan2'
AVG  : string = "avg"
CEIL  : string = 'ceil'
CHAR_LENGTH  : string = 'charLength'
COALESCE  : string = 'coalesce'
CONCAT  : string = 'concat'
CONCAT_SEPARATOR  : string = 'concatSeparator'
CONTAINS  : string = 'contains'
COS  : string = 'cos'
COS_SIMILARITY  : string = 'cosSimilarity'
COUNT  : string = 'count'
COUNT_DISTINCT  : string = 'countDistinct'
DATE_ADD  : string = 'dateAdd'
DATE_COMPARE  : string = 'dateCompare'
DATE_DAY  : string = 'dateDay'
DATE_DAY_OF_WEEK  : string = 'dateDayOfWeek'
DATE_DAY_OF_YEAR  : string = 'dateDayOfYear'
DATE_DAYS_IN_MONTH  : string = 'dateDaysInMonth'
DATE_DIFF  : string = 'dateDiff'
DATE_FORMAT  : string = 'dateFormat'
DATE_HOUR  : string = 'dateHour'
DATE_ISO_8601  : string = 'dateISO8601'
DATE_ISO_WEEK  : string = 'dateIsoWeek'
DATE_ISO_WEEK_YEAR  : string = 'dateIsoWeekYear'
DATE_LEAP_YEAR  : string = 'dateLeapYear'
DATE_LOCAL_TO_UTC  : string = 'dateLocalToUTC'
DATE_MILLISECOND  : string = 'dateMillisecond'
DATE_MINUTE  : string = 'dateMinute'
DATE_MONTH  : string = 'dateMonth'
DATE_QUARTER  : string = 'dateQuarter'
DATE_SECOND  : string = 'dateSecond'
DATE_SUBTRACT  : string = 'dateSubtract'
DATE_TIMESTAMP  : string = 'dateTimeStamp'
DATE_TIMEZONE  : string = 'dateTimezone'
DATE_TRUNC  : string = 'dateTrunc'
DATE_UTC_TO_LOCAL  : string = 'dateUTCToLocal'
DATE_YEAR  : string = 'dateYear'
DEGREES  : string = 'deg'
ENCODE_URI  : string = 'encodeURIComponent'
EXP  : string = 'exp'
EXP2  : string = 'exp2'
FIND_FIRST  : string = 'findFirst'
FIND_LAST  : string = 'findLast'
FIRST  : string = 'first'
FLOOR  : string = 'floor'
FNV64  : string = 'fnv64'
IPV4_FROM_NUMBER  : string = 'ipv4FromNumber'
IPV4_TO_NUMBER  : string = 'ipv4ToNumber'
IS_IPV4  : string = 'isIPV4'
JSON_PARSE  : string = 'jsonParse'
JSON_STRINGIFY  : string = 'jsonStringify'
LAST  : string = 'last'
LEFT  : string = 'left'
LENGTH  : string = 'length'
LEVENSHTEIN  : string = 'levenshtein'
LIKE  : string = 'like'
LOG  : string = 'log'
LOG10  : string = 'log10'
LOG2  : string = 'log2'
LOWER  : string = 'lower'
LTRIM  : string = 'ltrim'
MAX  : string = "max"
MD5  : string = 'md5'
MEDIAN  : string = "median"
MIN  : string = "min"
NOT_NULL  : string = 'notNull'
NTH  : string = 'nth'
PERCENTILE  : string = "percentile"
PLUCK  : string = 'pluck'
POP  : string = 'pop'
POSITION  : string = 'position'
POW  : string = 'pow'
PRODUCT  : string = "product"
PUSH  : string = 'push'
RADIANS  : string = 'rad'
RANDOM_TOKEN  : string = 'randomToken'
REMOVE  : string = 'remove'
REMOVES  : string = 'removes'
REVERSE  : string = 'reverse'
RIGHT  : string = 'right'
ROUND  : string = 'rnd'
RTRIM  : string = 'rtrim'
SHA1  : string = 'sha1'
SHA256  : string = 'sha256'
SHA512  : string = 'sha512'
SHIFT  : string = 'shift'
SIN  : string = 'sin'
SLICE  : string = 'slice'
SORTED  : string = 'sorted'
SORTED_UNIQUE  : string = 'sortedUnique'
SOUNDEX  : string = 'soundex'
SPLIT  : string = 'split'
SQRT  : string = 'sqrt'
STARTS_WITH  : string = 'startsWith'
SUBSTRING  : string = 'substring'
SUM  : string = "sum"
TAN  : string = 'tan'
TO_BASE64  : string = 'toBase64'
TO_CHAR  : string = 'toChar'
TO_HEX  : string = 'toHex'
TOKENS  : string = 'tokens'
TOMORROW  : string = 'tomorrow'
TRIM  : string = 'trim'
UNIQUE  : string = 'unique'
UNSHIFT  : string = 'unshift'
UPPER  : string = 'upper'
UUID  : string = 'uuid'
YESTERDAY  : string = 'yesterday'
BOOLEAN_FUNCTIONS  : array<string|int, mixed> = [self::CONTAINS, self::DATE_LEAP_YEAR, self::IS...
Functions that return boolean values.
UNBOUND_FUNCTIONS  : array<string|int, mixed> = [self::COALESCE, self::CONCAT_SEPARATOR, self::...
The codes whose string parameters are **not** bound, even when a binder is supplied — each because it already renders its parameter safely, and would quote or re-read a `@name` token into something meaningless:

Methods

apply()  : string
Apply a function to a key with optional parameters.
missingParameter()  : ValidationException
Builds the refusal of an arm whose operand is required.
unknownFunction()  : ValidationException
Builds the refusal of a name this catalogue does not carry.

Constants

CONCAT_SEPARATOR

public string CONCAT_SEPARATOR = 'concatSeparator'

DATE_DAY_OF_WEEK

public string DATE_DAY_OF_WEEK = 'dateDayOfWeek'

DATE_DAY_OF_YEAR

public string DATE_DAY_OF_YEAR = 'dateDayOfYear'

DATE_DAYS_IN_MONTH

public string DATE_DAYS_IN_MONTH = 'dateDaysInMonth'

DATE_ISO_WEEK_YEAR

public string DATE_ISO_WEEK_YEAR = 'dateIsoWeekYear'

DATE_LOCAL_TO_UTC

public string DATE_LOCAL_TO_UTC = 'dateLocalToUTC'

DATE_MILLISECOND

public string DATE_MILLISECOND = 'dateMillisecond'

DATE_UTC_TO_LOCAL

public string DATE_UTC_TO_LOCAL = 'dateUTCToLocal'

IPV4_FROM_NUMBER

public string IPV4_FROM_NUMBER = 'ipv4FromNumber'

BOOLEAN_FUNCTIONS

Functions that return boolean values.

private array<string|int, mixed> BOOLEAN_FUNCTIONS = [self::CONTAINS, self::DATE_LEAP_YEAR, self::IS_IPV4, self::LIKE, self::STARTS_WITH]

UNBOUND_FUNCTIONS

The codes whose string parameters are **not** bound, even when a binder is supplied — each because it already renders its parameter safely, and would quote or re-read a `@name` token into something meaningless:

private array<string|int, mixed> UNBOUND_FUNCTIONS = [self::COALESCE, self::CONCAT_SEPARATOR, self::CONTAINS, self::NOT_NULL, self::PLUCK]
  • contains / concatSeparator — routed through aqlValue(), which quotes and escapes ('mo\') || true || (\'nth'). A bound token would come back out as the literal string '@q_123456'.
  • coalesce / notNull — already inlined as strict AQL literals via json_encode, the one arm hardened when the option was introduced.
  • pluck — its parameter is an attribute name, not a value: AQL has no bind parameter for that position, and assertAttributeName() guards it.

Methods

apply()

Apply a function to a key with optional parameters.

public static apply(string $funcName, string $key[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $init = [] ]) : string

This method acts as a dispatcher that calls the appropriate AQL function wrapper based on the function name. It supports string, number, and array functions.

Parameters
$funcName : string

Function name (e.g., "trim", "lower", "abs", "avg")

$key : string

Current key expression (e.g., "doc.name")

$params : array<string|int, mixed> = []

Additional parameters for the function

$init : array<string|int, mixed> = []
Tags
throws
UnsupportedOperationException
ValidationException

When a pluck sub-field name is unsafe, when a required operand is missing, or when $funcName names no function of this catalogue.

example
FilterFunction::apply('lower', 'doc.name', []);
// Returns: "LOWER(doc.name)"

FilterFunction::apply('trim', 'doc.name', [1]);
// Returns: "TRIM(doc.name, 1)"

FilterFunction::apply('substring', 'doc.code', [0, 3]);
// Returns: "SUBSTRING(doc.code, 0, 3)"
Return values
string —

The key wrapped in the AQL function

missingParameter()

Builds the refusal of an arm whose operand is required.

private static missingParameter(string $funcName, string $operand) : ValidationException

Three entries of the catalogue take a second operand that has no meaningful default: AQL has no "position of nothing", no "similarity with nothing" and no "distance to nothing" — each of those functions is binary. Called bare, they used to fail in two unhelpful ways: a TypeError for a null handed to a non-nullable parameter, which is a fatal no caller declares or catches, or a silent no-op returning the key untouched, which quietly changes what the filter means — POSITION(doc.tags, "x") == true becomes doc.tags == true, a well-formed answer that matches nothing.

A ValidationException is the refusal apply() already declares, and it names both the arm and the operand it wanted.

Parameters
$funcName : string
$operand : string
Return values
ValidationException

unknownFunction()

Builds the refusal of a name this catalogue does not carry.

private static unknownFunction(string $funcName) : ValidationException

The arm used to return the key untouched, on the reading that an unknown name asks for nothing. It asks for something the engine cannot deliver, which is not the same: DATE_ISOWEEK(doc.startDate) == @week silently became doc.startDate == @week, and no date is ever equal to 34 — a well-formed query, in 200, matching nothing. A caller mistyping dateIsoWeek therefore read the collection as empty.

A function name is a closed identifier: it belongs to the catalogue or it does not, so there is no ambiguity to preserve and nothing to keep for compatibility. alterExpression() refuses before reaching here — it knows who wrote the chain and answers accordingly. This arm is the backstop for the callers that reach apply() directly.

Parameters
$funcName : string
Return values
ValidationException
On this page

Search results