Skip to main content

GravityMath_Engine

Wrapper for the Hoa Math package

See Also​

Source: includes/class-gravitymath-engine.php:10

Details​

  • Kind: class
  • Namespace: (global)

Properties​

PropertyTypeDescription
$instanceGravityMath_Engine

Methods​

MethodDescription
get_instance()Get the instance of the class.
result()Parse and evaluate an expression.
result_or_fallback()Parses and evaluates an expression, and when that fails, the expression $fallback returns instead.

Method Reference​

get_instance()​

public static function get_instance()

Get the instance of the class.

Returns​

Since: 2.5.0

Source: includes/class-gravitymath-engine.php:39

result()​

function result( $expression='' )

Parse and evaluate an expression.

Parameters​

NameTypeDefaultDescription
$expressionstring''The expression to evaluate.

Returns​

  • float | string

Since: 1.0

Source: includes/class-gravitymath-engine.php:80

result_or_fallback()​

public function result_or_fallback( $expression, callable $fallback )

Parses and evaluates an expression, and when that fails, the expression $fallback returns instead.

Parameters​

NameTypeDefaultDescription
$expressionstringThe expression to evaluate.
$fallbackcallableReturns the expression to try when $expression fails. Only called then.

Returns​

  • float | string

Throws​

  • Throwable — The error from $expression when both fail.

Since: 2.14.0

Source: includes/class-gravitymath-engine.php:102