Phi function reference

 

Function reference

The following functions from PHP and Twig are available in Phi:

  • abs(number)

    returns number

    Returns the absolute value of a number.

  • acos(number)

    returns radians

    Returns the arc cosine (in radians) of the input.

  • acosh(number)

    returns number

    Returns the inverse hyperbolic cosine of the input.

  • array(numbers/strings)

    returns array

    This combines its inputs together into an array.

  • array_merge(arrays)

    returns array

    This merges two or more arrays together into one array.

  • asin(number)

    returns radians

    Returns the arc sine (in radians) of the input.

  • asinh(number)

    returns number

    Returns the inverse hyperbolic sine of the input.

  • atan(number)

    returns radians

    Returns the arc tangent (in radians) of the input.

  • atan2(number)

    returns number

  • atanh(number)

    returns number

    Returns the inverse hyperbolic tangent of the input.

  • base_convert(number, frombase, tobase)

    returns string

    Converts a number between bases. E.g. base_convert('17', 8, 10) == 15

  • bindec(binary-string)

    returns number

    Converts a binary string to a number. E.g. base_convert('101') == 5

  • c(numbers/strings)

    returns array

    An alias of array(), this combines its inputs together into an array.

  • ceil(number)

    returns number

    Rounds a float up to the nearest integer value.

  • cos(radians)

    returns number

    Returns the cosine of the input, which needs to be in radians.

  • cosh(number)

    returns number

    Returns the hyperbolic cosine of the input.

  • count(array)

    returns number

    Counts the number of elements in an array.

  • cycle(array, index)

    returns element

    Returns an element from an array at the specified index. If the specified index is too high then it will wrap round back to the start of the array.

  • decbin(number)

    returns binary-string

    Converts an integer into a binary string, e.g. decbin(5) == '101'.

  • dechex(number)

    returns hexadecimal-string

    Converts an integer into a hexadecimal string, e.g. dechex(15) == 'F'.

  • decoct(number)

    returns octal-string

    Converts an integer into an octal string, e.g. decoct(15) == '17'.

  • deg2rad(degrees)

    returns radians

    Converts an an in degrees into a number in radians.

  • dump(string)

    returns null

    An alias of print(), This allows you to check the value of variables while testing your code. The data processor ignores this function.

  • factorial(number)

    returns number

    Returns the factorial of the number entered.

  • firstQuartile(array/numbers)

    returns number

    Returns the first or lower quartile of the numbers entered.

  • float(mixed)

    returns number

    Converts an integer or a string to a floating point number if possible.

  • floor(number)

    returns number

    Rounds a float down to the nearest integer value.

  • gcd(number, number)

    returns number

    Returns the greatest common divider of two integers.

  • getAllChildIds(schema[, nodeId])

    returns value

    This gives you all of the children of the current asset or data pool.

    You can optionally filter by a specific schema.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getHistoricValue(key, timestamp[, nodeId])

    returns value

    Looks up the value of a field at the specified timestamp.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getImmediateChildIds(schema[, nodeId])

    returns value

    This gives you all of the immediate children of the current asset or data pool.

    You can optionally filter by a specific schema.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getInheritedMetadata(key[, nodeId])

    returns value

    Looks up the value of a metadata field.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

    If the requested field was not set for the specified asset or data pool, the system will check the data pools above in the hierarchy until it finds one with the field set.

  • getMetadata(key[, nodeId])

    returns value

    Looks up the value of a metadata field.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getMinValue(key, fromTimestamp, toTimestamp[, assetIds])

    returns value

    Looks up the smallest value of a field between the specified timestamps.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getMaxValue(key, fromTimestamp, toTimestamp[, assetIds])

    returns value

    Looks up the largest value of a field between the specified timestamps.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds() or getAllChildIds() function to override this.

  • getTimestamp(description[, timestamp])

    returns number

    Generates a timestamp as described above.

  • hexdec(hexadecimal-string)

    returns number

    Converts a hexadecimal string into an integer, e.g. hexdec('F') == 15.

  • int(mixed)

    returns number

    Converts a floating point number or a string to an integer if possible.

  • is_finite(number)

    returns boolean

    Checks whether a float is finite.

  • is_infinite(number)

    returns boolean

    Checks whether a float is infinite.

  • is_nan(number)

    returns boolean

    Checks for floats marked as "non a number", e.g. is_nan(sqrt(-1)).

  • lcm(number, number)

    returns number

    Returns the least common multiple of two integers.

  • length(array/string)

    returns number

    Returns the length of a string, or the number of elements in an array.

  • list(numbers/strings)

    returns array

    An alias of array(), this combines its inputs together into an array.

  • log(number[, base])

    returns number

    Calculates a logarithm.

  • log10(number)

    returns number

    Calculates the base-10 logarithm of the input.

  • lowerQuartile(array/numbers)

    returns number

    Returns the first or lower quartile of the numbers entered.

  • max(array/numbers)

    returns number

    Returns the largest of the numbers entered.

  • mean(array/numbers)

    returns number

    Returns the mean of the numbers entered.

  • median(array/numbers)

    returns number

    Returns the median of the numbers entered.

  • min(array/numbers)

    returns number

    Returns the smallest of the numbers entered.

  • mode(array/numbers)

    returns number

    Returns the most common value from the numbers entered.

  • octdec(octal-string)

    returns number

    Converts an octal string into an integer, e.g. octdec('17') == 15.

  • paste(strings)

    returns string

    Concatenates strings together, joining them together with a space between each.

  • print(string)

    returns null

    This allows you to check the value of variables while testing your code. The data processor ignores this function.

  • product(array/numbers)

    returns number

    Returns the product of the numbers entered.

  • query(fromTimestamp, toTimestamp, nodeIds)

    returns value

    This finds all of the data for the specified assets, between the specified timestamps.

    This returns a cursor of results that you can loop through using a for () loop.

  • rad2deg(radians)

    returns degrees

    Converts an an in degrees into a number in radians.

  • random(array/number/string)

    returns element/number/character

    Returns a random element from an array, a random character from a string, or a random integer less than or equal to the number provided.

  • range(start, stop[, step])

    returns array

    Generates an array of integers.

  • rev(array/numbers/strings)

    returns array

    An alias of reverse, this returns an array with the inputs in reverse order.

  • reverse(array/numbers/strings)

    returns array

    This returns an array with the inputs in reverse order.

  • round(number[, precision])

    returns number

    Rounds the input to the specified number of decimal places.

  • setValue(key, value)

    returns null

    Sets the value of a calculated field, as described above.

  • shuffle(array/numbers/strings)

    returns array

    This makes a randomly shuffled array from the inputs.

  • sin(radians)

    returns number

    Returns the sine of the input, which needs to be in radians.

  • sinh(number)

    returns number

    Returns the hyperbolic sine of the input.

  • sort(array/numbers/strings)

    returns array

    This makes a sorted array from the inputs.

  • sqrt(number)

    returns number

    Returns the square root of the input.

  • standardDev(array/numbers)

    returns number

    Returns the standard deviation of the numbers entered.

  • string(mixed)

    returns string

    Converts a number to a string.

  • sum(array/numbers)

    returns number

    Returns the total of the numbers entered.

  • tan(radians)

    returns number

    Returns the tangent of the input, which needs to be in radians.

  • tanh(number)

    returns number

    Returns the hyperbolic tangent of the input.

  • thirdQuartile(array/numbers)

    returns number

    Returns the third or upper quartile of the numbers entered.

  • trim(string)

    returns string

    Strips whitespace from the beginning and end of a string.

  • upperQuartile(array/numbers)

    returns number

    Returns the third or upper quartile of the numbers entered.