Helper class containing calculation functions for use in event classes.

package Gems
subpackage Event
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.4

 Methods

Adds value to $results when it is different from the value in $tokenAnswers.

addWhenChanged(string $name, mixed $value, array $results, array $tokenAnswers) : boolean
Static

Parameters

$name

string

The name of the values

$value

mixed

The value to compare to

$results

array

The results to add to

$tokenAnswers

array

The answers to compare to

Returns

booleanTrue when the value changed.

Returns the avarage over those $fieldNames values that exist in $tokenAnswers and are integers.

averageInt(array $tokenAnswers, mixed $fieldNames) : float
Static

Parameters

$tokenAnswers

array

Array containing the answers

$fieldNames

mixed

An array of those names that should be used or a string that should occur in all names that have to be selected.

Returns

float

Checks all $values for a change against $tokenAnswers as floats

checkFloatChanged(array $values, array $tokenAnswers) : array
Static

Parameters

$values

array

$tokenAnswers

array

Returns

arrayThose values that were changed.

Checks all $values for a change against $tokenAnswers as integer

checkIntegerChanged(array $values, array $tokenAnswers) : array
Static

Parameters

$values

array

$tokenAnswers

array

Returns

arrayThose values that were changed.

Reverses the code value of an item.

reverseCode(integer $code, integer $min, integer $max) : integer
Static

Used when a code can have the values 1 to 5 or 0 to 9 and the reverse outcome should be used, e.g.: 5 = 1, 4 = 2, 3 = 3, 2 = 4, 1 = 5.

Parameters

$code

integer

$min

integer

$max

integer

Returns

integer

Rounds the value with a fixed number of decimals, padding zeros when required.

roundFixed(\numeric $value, integer $decimals = 2) : string
Static

Parameters

$value

\numeric

$decimals

integer

Returns

string

Returns the sum over those $fieldNames values that exist in $tokenAnswers and are integers

sumInt(array $tokenAnswers, mixed $fieldNames) : integer
Static

Parameters

$tokenAnswers

array

Array containing the answers

$fieldNames

mixed

An array of those names that should be used or a string that should occur in all names that have to be selected.

Returns

integer

Finds those tokenAnswers array keys that contain "fieldNames" in their key.

_arrayFindName(array $tokenAnswers, string $fieldNames) : array
Static

Parameters

$tokenAnswers

array

$fieldNames

string

Returns

array