ApiOpenStudio PHPDoc

Math extends ProcessorEntity

Class Math

Processor class to implement basic mathematical formulas.

Table of Contents

$id  : mixed
Processor ID.
$db  : ADOConnection|null
DB connections.
$details  : array<string|int, mixed>
{@inheritDoc}
$logger  : MonologWrapper
Logger object.
$meta  : array<string|int, mixed>
Metadata for the processor.
$request  : Request
All the request details.
__construct()  : mixed
details()  : array<string|int, mixed>
Return details for processor.
process()  : DataContainer
{@inheritDoc}
val()  : mixed|DataContainer
Process a variable into a final result for the processor.
generateParams()  : array<string|int, mixed>
Generate the params array for the sql search.
isDataContainer()  : bool
Validate if a set of data is wrapped in a DataContainer object.
validateAllowedTypes()  : void
Validate an input for allowed variable types
validateAllowedValues()  : void
Validate an input for allowed values.

Properties

$id

Processor ID.

public mixed $id = ''

Processor ID.

$details

{@inheritDoc}

protected array<string|int, mixed> $details = [ 'name' => 'Math', 'machineName' => 'math', // phpcs:ignore 'description' => <<<TEXT Formula is a processor for parsing and evaluating mathematical formulas. In the case of the following, a result of * NaN, "NaN" is returned. * INF, "Infinity" is returned. * -INF, "-Infinity" is returned. Supports: Math operators +, -, *, / and power (^) plus () Logical operators (==, !=, <, <, >=, <=, &&, ||) Conditional If logic Unlimited variable name lengths Unary Plus and Minus (e.g. +3 or -sin(12)) Pi and Euler's number support to 11 decimal places Math functions abs acos (arccos) acosh arcctg (arccot, arccotan) arcsec arccsc (arccosec) asin (arcsin) atan (atn, arctan, arctg) atan2 atanh avg bindec ceil cos cosec (csc) cosh ctg (cot, cotan, cotg, ctn) decbin dechex decoct deg2rad exp expm1 floor fmod hexdec hypot if intdiv log (ln) log10 (lg) log1p max min octdec pi pow rad2deg round sec sin sinh sqrt tan (tn, tg) tanh e.g. 10 + log(0) (-5)^500+5 abs(-x^500)/pi INF + x 3*x^2 - 4*y + 3/y 5/-x +-z sqrt(x^y/pi) abs(a-b^3) x-tan(-4)^3 (y)^x XeY+5^30 2^(sqrt(x)^3) (-1E3+1)^(1E+x) 4^-0.8e+1/x --sin(c) exp((-3)^2) Example: processor: math id: example formula formula: 3*x^2 - 4*y + 3/y variables: processor: var_object id: formula variables attributes: - processor: var_field id: variable 1 key: x value: -4 - processor: var_field id: variable 2 key: y value: 8 RESULT: 16.38 TEXT , 'menu' => 'Math', 'input' => ['formula' => ['description' => 'The formula.', 'cardinality' => [1, 1], 'literalAllowed' => true, 'limitProcessors' => [], 'limitTypes' => ['text'], 'limitValues' => [], 'default' => null], 'variables' => ['description' => 'The variables. This is an object of var-field.', 'cardinality' => [0, 1], 'literalAllowed' => true, 'limitProcessors' => ['var_object'], 'limitTypes' => [], 'limitValues' => [], 'default' => []]], ]

Details of the processor.

$meta

Metadata for the processor.

protected array<string|int, mixed> $meta

$request

All the request details.

protected Request $request

Request.

Methods

__construct()

public __construct(array<string|int, mixed> &$meta, Request &$request[, MonologWrapper|null $logger = null ]) : mixed
Parameters
$meta : array<string|int, mixed>

Metadata for the processor.

$request : Request

The full request object.

$logger : MonologWrapper|null = null

The logger.

Return values
mixed

details()

Return details for processor.

public details() : array<string|int, mixed>
Return values
array<string|int, mixed>

val()

Process a variable into a final result for the processor.

public val(string $key[, bool|null $rawData = false ]) : mixed|DataContainer

This method can be used to process a value in its meta to return a final result that it can use. If the object is a processor, then it will process that down to a final return value, or if the obj is a simple value, then it will return that. Anything else will return an error object.

Setting $realValue to true will force the value to be the actual value, rather than a potential dataContainer.

Parameters
$key : string

The key for the input variable in the meta.

$rawData : bool|null = false

Return the raw data or a DataContainer.

Tags
throws
ApiException

Invalid key or data.

Return values
mixed|DataContainer

generateParams()

Generate the params array for the sql search.

protected generateParams(string|null $keyword, array<string|int, mixed>|null $keywordCols, string|null $orderBy, string|null $direction) : array<string|int, mixed>
Parameters
$keyword : string|null

Search keyword.

$keywordCols : array<string|int, mixed>|null

Columns to search for the keyword.

$orderBy : string|null

Order by column.

$direction : string|null

Order direction.

Return values
array<string|int, mixed>

isDataContainer()

Validate if a set of data is wrapped in a DataContainer object.

protected isDataContainer(mixed $data) : bool
Parameters
$data : mixed

DataContainer or raw data.

Return values
bool

validateAllowedTypes()

Validate an input for allowed variable types

private validateAllowedTypes(string $type, array<string|int, mixed> $limitTypes, int $min, string $key) : void
Parameters
$type : string

Input value type.

$limitTypes : array<string|int, mixed>

List of limit on variable types.

$min : int

Minimum number of values.

$key : string

The key of the input being validated.

Tags
throws
ApiException

Invalid data type.

Return values
void

validateAllowedValues()

Validate an input for allowed values.

private validateAllowedValues(mixed $val, array<string|int, mixed> $limitValues, int $min, string $key) : void
Parameters
$val : mixed

Input value.

$limitValues : array<string|int, mixed>

List of allowed values.

$min : int

Minimum number of values.

$key : string

The key of the input being validated.

Tags
throws
ApiException

Invalid value.

Return values
void

Search results