class BusinessRule

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

Properties

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

Methods

void
__construct(Simulator $simulator, string $elementId, int $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

int
getId()

Returns the business rule ID

void
setId(int $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(RuleAction $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(RuleAction $elseAction)

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

array
getExtendedConditions()

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

array
ruleConnector(Connector|Condition $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, string $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 152
void __construct(Simulator $simulator, string $elementId, int $id, string $name)

Constructor of class BusinessRule

Parameters

Simulator $simulator Simulator object that defines this BusinessRule
string $elementId Generated id of this business rule for the DOM element in the browser
int $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 167
Simulator getSimulator()

Returns the Simulator object that defines this BusinessRule

Return Value

Simulator the Simulator object

at line 178
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 191
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 202
int getId()

Returns the business rule ID

Return Value

int The business rule id

at line 214
void setId(int $id)

Sets the business rule ID

Parameters

int $id The business rule id

Return Value

void

at line 225
string getName()

Returns the business rule name

Return Value

string the Business rule name

at line 237
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 248
string getLabel()

Returns the business rule label

Return Value

string The business rule label

at line 260
void setLabel(string $label)

Sets the business rule label

Parameters

string $label The business rule label

Return Value

void

at line 271
string getConditions()

Returns the business rule conditions

Return Value

string The business rule conditions

at line 283
void setConditions(string $conditions)

Sets the business rule conditions

Parameters

string $conditions The business rule conditions

Return Value

void

at line 294
Connector getConnector()

Returns the Connector object of this business rule

Return Value

Connector The Connector object of this business rule

at line 306
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 317
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 329
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 341
void addIfAction(RuleAction $ifAction)

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

Parameters

RuleAction $ifAction The action to be added

Return Value

void

at line 352
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 364
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 376
void addElseAction(RuleAction $elseAction)

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

Parameters

RuleAction $elseAction Action The action to be added

Return Value

void

at line 389
array 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

array The conditions in a readable format

at line 410
array ruleConnector(Connector|Condition $pconnector)

Transforms a connector into an array of conditions

A connector is either a Condition object or a Connector object

Parameters

Connector|Condition $pconnector The connector

Return Value

array The array of conditions

at line 441
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 484
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 556
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 586
protected void optimize(array $ruleData)

function optimize

Parameters

array $ruleData &$ruleData The array of parsed conditions

Return Value

void

at line 613
protected bool optimizeCond(array $ruleData, string $connector)

function optimizeCond

Parameters

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

Return Value

bool the value of optimized

at line 640
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