class BusinessRule

This class allows the storage and retrieval of the attributes of a business rule

Properties

private Simulator $simulator
private string $elementId
private string $id
private string $name
private string $label
private string $conditions
private Connector $connector
private array $ifActions
private array $elseActions
private null $translator
private array $inverseOperators

Methods

void
__construct(Simulator $simulator, int $elementId, string $id, string $name)

Constructor of class BusinessRule

getSimulator()

Returns the Simulator object that defines this BusinessRule

string
getElementId()

Returns the generated id of this business rule for the DOM element in the browser

void
setElementId(string $elementId)

Sets the generated id of this business rule for the DOM element in the browser

string
getId()

Returns the business rule ID

void
setId(string $id)

Sets the business rule ID

string
getName()

Returns the business rule name

void
setName(string $name)

Sets the business rule name

string
getLabel()

Returns the business rule label

void
setLabel(string $label)

Sets the business rule label

string
getConditions()

Returns the business rule conditions

void
setConditions(string $conditions)

Sets the business rule conditions

getConnector()

Returns the Connector object of this business rule

void
setConnector(Connector $connector)

Sets the Connector object of this business rule

array
getIfActions()

Returns the list of actions that must be executed if the conditions of this business rule are verified.

void
setIfActions(array $ifActions)

Sets the list of actions that must be executed if the conditions of this business rule are verified.

void
addIfAction(Action $ifAction)

Adds an action to the list of actions that must be executed if the conditions of this business rule are verified.

array
getElseActions()

Returns the list of actions that must be executed if the conditions of this business rule are NOT verified.

void
setElseActions(array $elseActions)

Sets the list of actions that must be executed if the conditions of this business rule are NOT verified.

void
addElseAction($elseAction)

Adds an action to the list of actions that must be executed if the conditions of this business rule are NOT verified.

string
getExtendedConditions()

Returns the conditions of this business rule in a readable format.

array
ruleConnector($pconnector)

Transforms a connector into an array of conditions

string
getPlainOperator(string $operator, string $type)

Returns the readable format of an operator

void
plainConditions(array $ruleData)

Transforms the array of parsed conditions of this business rule into an array of conditions in a readable format

void
negate(array $ruleData)

Transforms the array of parsed conditions of this business rule into their negative forms

void
optimize(array $ruleData)

function optimize

bool
optimizeCond(array $ruleData, Connector $connector)

function optimizeCond

array
parseConditions()

Parses the conditions of this business rule in an array to be usable by the administration module.

Details

at line 153
void __construct(Simulator $simulator, int $elementId, string $id, string $name)

Constructor of class BusinessRule

Parameters

Simulator $simulator Simulator object that defines this BusinessRule
int $elementId Generated id of this business rule for the DOM element in the browser
string $id ID of this business rule
string $name Name of this business rule without spaces or special or accented characters

Return Value

void

at line 168
Simulator getSimulator()

Returns the Simulator object that defines this BusinessRule

Return Value

Simulator the Simulator object

at line 179
string getElementId()

Returns the generated id of this business rule for the DOM element in the browser

Return Value

string The generated id of this business rule

at line 192
void setElementId(string $elementId)

Sets the generated id of this business rule for the DOM element in the browser

Parameters

string $elementId The generated id of this business rule

Return Value

void

at line 203
string getId()

Returns the business rule ID

Return Value

string The business rule id

at line 215
void setId(string $id)

Sets the business rule ID

Parameters

string $id The business rule id

Return Value

void

at line 226
string getName()

Returns the business rule name

Return Value

string the Business rule name

at line 238
void setName(string $name)

Sets the business rule name

Parameters

string $name The business rule name without spaces or special or accented characters

Return Value

void

at line 249
string getLabel()

Returns the business rule label

Return Value

string The business rule label

at line 261
void setLabel(string $label)

Sets the business rule label

Parameters

string $label The business rule label

Return Value

void

at line 272
string getConditions()

Returns the business rule conditions

Return Value

string The business rule conditions

at line 284
void setConditions(string $conditions)

Sets the business rule conditions

Parameters

string $conditions The business rule conditions

Return Value

void

at line 295
Connector getConnector()

Returns the Connector object of this business rule

Return Value

Connector The Connector object of this business rule

at line 307
void setConnector(Connector $connector)

Sets the Connector object of this business rule

Parameters

Connector $connector The Connector object of this business rule

Return Value

void

at line 318
array getIfActions()

Returns the list of actions that must be executed if the conditions of this business rule are verified.

Return Value

array The list of actions

at line 330
void setIfActions(array $ifActions)

Sets the list of actions that must be executed if the conditions of this business rule are verified.

Parameters

array $ifActions The list of actions

Return Value

void

at line 342
void addIfAction(Action $ifAction)

Adds an action to the list of actions that must be executed if the conditions of this business rule are verified.

Parameters

Action $ifAction The action to be added

Return Value

void

at line 353
array getElseActions()

Returns the list of actions that must be executed if the conditions of this business rule are NOT verified.

Return Value

array The list of actions

at line 365
void setElseActions(array $elseActions)

Sets the list of actions that must be executed if the conditions of this business rule are NOT verified.

Parameters

array $elseActions The list of actions

Return Value

void

at line 377
void addElseAction($elseAction)

Adds an action to the list of actions that must be executed if the conditions of this business rule are NOT verified.

Parameters

$elseAction

Return Value

void

at line 390
string getExtendedConditions()

Returns the conditions of this business rule in a readable format.

If the business rule has no connector, the conditions are first parsed then optimized.

Return Value

string The conditions in a readable format

at line 411
private array ruleConnector($pconnector)

Transforms a connector into an array of conditions

A connector is either a Condition object or a Connector object

Parameters

$pconnector

Return Value

array The array of conditions

at line 439
protected string getPlainOperator(string $operator, string $type)

Returns the readable format of an operator

Parameters

string $operator The operator
string $type Type of operand to which the operator applies

Return Value

string The readable format of the operator

at line 482
protected void plainConditions(array $ruleData)

Transforms the array of parsed conditions of this business rule into an array of conditions in a readable format

Parameters

array $ruleData &$ruleData The array of parsed conditions

Return Value

void

at line 553
protected void negate(array $ruleData)

Transforms the array of parsed conditions of this business rule into their negative forms

Parameters

array $ruleData &$ruleData The array of parsed conditions

Return Value

void

at line 583
protected void optimize(array $ruleData)

function optimize

Parameters

array $ruleData &$ruleData The array of parsed conditions

Return Value

void

at line 610
protected bool optimizeCond(array $ruleData, Connector $connector)

function optimizeCond

Parameters

array $ruleData &$ruleData
Connector $connector Connector that defines this BusinessRule

Return Value

bool the value of optimized

at line 637
protected array parseConditions()

Parses the conditions of this business rule in an array to be usable by the administration module.

.

Return Value

array The array of the parsed conditions

Exceptions

Exception if an error occurs