Data
class Data extends DatasetChild
This class allows the storage and retrieval of the attributes of a data item.
The Data object is where most of the information used by a simulator is stored:
- User input
- information from data sources
- intermediate calculation data
- information returned to the user.
The data item can have one of the following type:
- date: a date stored in the d/m/Y format
- boolean: the value of the data item can be true or false
- number: a numeric data with decimal places
- integer: a numeric value without decimal places.
- text: a short text
- textarea: a long text
- money: a numeric data with decimal places. The value of the data will be displayed with the currency symbol
- choice: the value of the data is chosen from a list of choices
- multichoice: the values of the data are chosen from a list of choices
- percent: a numeric data with decimal places. The display of the value of the data will be followed by the % symbol.
- table: the data item has an associated Table object
- department: a departement code
- region: a region code
- country: a country code
Properties
| protected Simulator | $simulator | from DatasetChild | |
| protected int | $id | from DatasetChild | |
| protected string | $name | from DatasetChild | |
| protected string | $label | from DatasetChild | |
| protected string | $description | from DatasetChild | |
| protected bool | $error | from DatasetChild | |
| protected array | $errorMessages | from DatasetChild | |
| protected bool | $warning | from DatasetChild | |
| protected array | $warningMessages | from DatasetChild | |
| protected bool | $used | from DatasetChild | |
| private string | $type | ||
| private string | $min | ||
| private string | $unparsedMin | ||
| private string | $max | ||
| private string | $unparsedMax | ||
| private string | $default | ||
| private string | $unit | ||
| private string | $unparsedDefault | ||
| private int | $round | ||
| private string | $content | ||
| private string | $source | ||
| private string | $unparsedIndex | ||
| private string | $index | ||
| private bool | $memorize | ||
| private array | $choices | ||
| private ChoiceSource | $choiceSource | ||
| private Table | $table | ||
| private string | $value | ||
| private array | $rulesDependency | ||
| private int | $inputStepId | 
Methods
Returns the Simulator object that uses this dataset child
Sets the description of this dataset child.
Returns the state of use of this dataset child by the current simulation step
Returns the state of use of this dataset child by the current simulation step
Sets the state of use of this dataset child by the current simulation step
Determines whether this dataset child has a issued error or not
Adds a message to the list of error messages.
Removes a message from the list of error messages.
Determines whether this dataset child has a issued warning or not
Sets the list of warning messages.
Adds a message to the list of warning messages.
Removes a message from the list of warning messages.
Returns the class name of this dataset child. It's either "Data" or "DataGroup".
Returns the type of this data item
Sets the type of this data item
Returns the minimum value of this data item
Returns the arithmetic expression used to calculate the minimum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
Sets the minimum value of this data item
Returns the arithmetic expression used to calculate the minimum value of this data item.
Sets the arithmetic expression used to calculate the minimum value of this data item.
Returns the maximum value of this data item
Returns the arithmetic expression used to calculate the maximum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
Sets the maximum value of this data item
Returns the arithmetic expression used to calculate the minimum value of this data item.
Sets the arithmetic expression used to calculate the minimum value of this data item.
Returns the default value of this data item
Returns the arithmetic expression used to calculate the default value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
Sets the default value of this data item
Returns the arithmetic expression used to calculate the default value of this data item.
Sets the arithmetic expression used to calculate the default value of this data item.
Returns the unit (measurement) text of this data item.
Sets the unit(measurement) text of this data item.
Returns the number of decimal places for this data item.
Sets the number of decimal places for this data item. The last digit of the value of the data will be rounded to the nearest integer.
Returns the arithmetic expression used to calculate the current value of this data item.
Returns the arithmetic expression used to calculate the value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
Sets the arithmetic expression used to calculate the value of this data item.
Returns the id of the source if this data item is filled with the result of a query on a data source
Returns the arithmetic expression used to calculate the id of the source where the ids (prefixed with #) of the data are replaced by their labels.
Sets the id of the source if this data item is filled with the result of a query on a data source
Returns the key of the associative array of the result if this data item is filled with the result of a query on a data source
Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source. The ids (prefixed with #) of the data are replaced by their labels.
Sets the key of the associative array of the result if this data item is filled with the result of a query on a data source
Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.
Sets the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.
Retrieves the memorize attribute of this data item.
Returns the memorize attribute of this data item.
Determines whether the value of this data should be stored in a cookie in the user's browser or not.
Returns the list of Choice Objects of this data item.
Returns the label of the choice corresponding to the current value of this data item.
Retrieves the label of a choice by its value from the list of choices associated with that data item.
Sets the list of Choice Objects of this data item.
Retrieves a Choice object by its id in the list of choices of this data item.
Returns the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.
Sets the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.
Returns the Table object associated with this data item if the type of this data is "table".
Retrieves the current value of this data item
Returns the current value of this data item in a string
Sets the current value of this data item
Retrieves the id of the step where the user enters the value of this data item
Sets the id of the step where the user enters the value of this data item
Returns the list of business rules that use this data item
Sets the list of business rules that use this data item
Adds a business rule id to the list of business rules that use this data item
Removes a business rule id from the list of business rules that use this data item
Checks the value of this data item according to its type
Returns the label of the data item whose identifier is the first element of the given array. The argument is an array because this method is the callback function of a preg_replace_callback.
Replaces all data id (prefixed with #) by its label in the given text
Details
        at         line 234
                            void
    __construct(Simulator $simulator, int $id, string $name)
        
    
    Constructor of class Data
        in DatasetChild at         line 144
                            Simulator
    getSimulator()
        
    
    Returns the Simulator object that uses this dataset child
        in DatasetChild at         line 155
                            int
    getId()
        
    
    Returns the ID of this dataset child.
        in DatasetChild at         line 167
                            void
    setId(int $id)
        
    
    Sets the ID of this dataset child.
        in DatasetChild at         line 178
                            string
    getName()
        
    
    Returns the name of this dataset child.
        in DatasetChild at         line 190
                            void
    setName(string $name)
        
    
    Sets the name of this dataset child.
        in DatasetChild at         line 201
                            string
    getLabel()
        
    
    Returns the label of this dataset child.
        in DatasetChild at         line 213
                            void
    setLabel(string $label)
        
    
    Sets the label of this dataset child.
        in DatasetChild at         line 224
                            string
    getDescription()
        
    
    Returns the description of this dataset child.
        in DatasetChild at         line 236
                            void
    setDescription(string $description)
        
    
    Sets the description of this dataset child.
        in DatasetChild at         line 247
                            bool
    isUsed()
        
    
    Returns the state of use of this dataset child by the current simulation step
        in DatasetChild at         line 258
                            bool
    getUsed()
        
    
    Returns the state of use of this dataset child by the current simulation step
        in DatasetChild at         line 270
                            void
    setUsed(bool $used)
        
    
    Sets the state of use of this dataset child by the current simulation step
        in DatasetChild at         line 281
                            bool
    isError()
        
    
    Returns the error attribute of this dataset child
        in DatasetChild at         line 292
                            bool
    getError()
        
    
    Returns the error attribute of this dataset child
        in DatasetChild at         line 304
                            void
    setError(bool $error)
        
    
    Determines whether this dataset child has a issued error or not
        in DatasetChild at         line 315
                            array
    getErrorMessages()
        
    
    Returns the list of error messages.
        in DatasetChild at         line 327
                            void
    setErrorMessages(array $errorMessages)
        
    
    Sets the list of error messages.
        in DatasetChild at         line 339
                            void
    addErrorMessage(string $errorMessage)
        
    
    Adds a message to the list of error messages.
        in DatasetChild at         line 353
                            void
    removeErrorMessage(int $index)
        
    
    Removes a message from the list of error messages.
        in DatasetChild at         line 364
                            bool
    isWarning()
        
    
    Returns the warning attribute of this dataset child
        in DatasetChild at         line 375
                            bool
    getWarning()
        
    
    Returns the warning attribute of this dataset child
        in DatasetChild at         line 387
                            void
    setWarning(bool $warning)
        
    
    Determines whether this dataset child has a issued warning or not
        in DatasetChild at         line 398
                            array
    getWarningMessages()
        
    
    Returns the list of warning messages.
        in DatasetChild at         line 410
                            void
    setWarningMessages(array $warningMessages)
        
    
    Sets the list of warning messages.
        in DatasetChild at         line 422
                            void
    addWarningMessage(string $warningMessage)
        
    
    Adds a message to the list of warning messages.
        in DatasetChild at         line 436
                            void
    removeWarningMessage(int $index)
        
    
    Removes a message from the list of warning messages.
        in DatasetChild at         line 447
                            string
    getClass()
        
    
    Returns the class name of this dataset child. It's either "Data" or "DataGroup".
        at         line 245
                            string
    getType()
        
    
    Returns the type of this data item
        at         line 274
                            void
    setType(string $type)
        
    
    Sets the type of this data item
The data item can have one of the following type:
- date: a date stored in the d/m/Y format
- boolean: the value of the data item can be true or false
- number: a numeric data with decimal places
- integer: a numeric value without decimal places.
- text: a short text
- textarea: a long text
- money: a numeric data with decimal places. The value of the data will be displayed with the currency symbol
- choice: the value of the data is chosen from a list of choices
- multichoice: the values of the data are chosen from a list of choices
- percent: a numeric data with decimal places. The display of the value of the data will be followed by the % symbol.
- table: the data item has an associated Table object
- department: a departement code
- region: a region code
- country: a country code
        at         line 288
                            string
    getMin()
        
    
    Returns the minimum value of this data item
        at         line 299
                            string
    getPlainMin()
        
    
    Returns the arithmetic expression used to calculate the minimum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
        at         line 311
                            void
    setMin(string $min)
        
    
    Sets the minimum value of this data item
        at         line 322
                            string
    getUnparsedMin()
        
    
    Returns the arithmetic expression used to calculate the minimum value of this data item.
        at         line 334
                            void
    setUnparsedMin(string $unparsedMin)
        
    
    Sets the arithmetic expression used to calculate the minimum value of this data item.
        at         line 345
                            string
    getMax()
        
    
    Returns the maximum value of this data item
        at         line 356
                            string
    getPlainMax()
        
    
    Returns the arithmetic expression used to calculate the maximum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
        at         line 368
                            void
    setMax(string $max)
        
    
    Sets the maximum value of this data item
        at         line 379
                            string
    getUnparsedMax()
        
    
    Returns the arithmetic expression used to calculate the minimum value of this data item.
        at         line 391
                            void
    setUnparsedMax(string $unparsedMax)
        
    
    Sets the arithmetic expression used to calculate the minimum value of this data item.
        at         line 402
                            string
    getDefault()
        
    
    Returns the default value of this data item
        at         line 413
                            string
    getPlainDefault()
        
    
    Returns the arithmetic expression used to calculate the default value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
        at         line 425
                            void
    setDefault(string $default)
        
    
    Sets the default value of this data item
        at         line 436
                            string
    getUnparsedDefault()
        
    
    Returns the arithmetic expression used to calculate the default value of this data item.
        at         line 448
                            void
    setUnparsedDefault(string $unparsedDefault)
        
    
    Sets the arithmetic expression used to calculate the default value of this data item.
        at         line 459
                            string
    getUnit()
        
    
    Returns the unit (measurement) text of this data item.
        at         line 471
                            void
    setUnit(string $unit)
        
    
    Sets the unit(measurement) text of this data item.
        at         line 484
                            int
    getRound()
        
    
    Returns the number of decimal places for this data item.
Useless if this data is not of type "number", "money" or "percent".
        at         line 498
                            void
    setRound(int $round)
        
    
    Sets the number of decimal places for this data item. The last digit of the value of the data will be rounded to the nearest integer.
Useless if this data is not of type "number", "money" or "percent".
        at         line 509
                            string
    getContent()
        
    
    Returns the arithmetic expression used to calculate the current value of this data item.
        at         line 520
                            string
    getPlainContent()
        
    
    Returns the arithmetic expression used to calculate the value of this data item where the ids (prefixed with #) of the data are replaced by their labels.
        at         line 532
                            void
    setContent(string $content)
        
    
    Sets the arithmetic expression used to calculate the value of this data item.
        at         line 543
                            string
    getSource()
        
    
    Returns the id of the source if this data item is filled with the result of a query on a data source
        at         line 557
                            string
    getPlainSource()
        deprecated
    
    deprecated
Returns the arithmetic expression used to calculate the id of the source where the ids (prefixed with #) of the data are replaced by their labels.
This function is no longer used.
        at         line 569
                            void
    setSource(string $source)
        
    
    Sets the id of the source if this data item is filled with the result of a query on a data source
        at         line 580
                            string
    getIndex()
        
    
    Returns the key of the associative array of the result if this data item is filled with the result of a query on a data source
        at         line 591
                            string
    getPlainIndex()
        
    
    Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source. The ids (prefixed with #) of the data are replaced by their labels.
        at         line 603
                            void
    setIndex(string $index)
        
    
    Sets the key of the associative array of the result if this data item is filled with the result of a query on a data source
        at         line 614
                            string
    getUnparsedIndex()
        
    
    Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.
        at         line 626
                            void
    setUnparsedIndex(string $unparsedIndex)
        
    
    Sets the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.
        at         line 639
                            bool
    isMemorize()
        
    
    Retrieves the memorize attribute of this data item.
Indicates whether the value of this data should be saved in a cookie in the user's browser.
        at         line 650
                            bool
    getMemorize()
        
    
    Returns the memorize attribute of this data item.
        at         line 662
                            void
    setMemorize(bool $memorize)
        
    
    Determines whether the value of this data should be stored in a cookie in the user's browser or not.
        at         line 675
                            array
    getChoices()
        
    
    Returns the list of Choice Objects of this data item.
If the type of this data is "choice" or "multichoice", the list of choices allows the user to select the value of this data item.
        at         line 686
                            string
    getChoiceLabel()
        
    
    Returns the label of the choice corresponding to the current value of this data item.
        at         line 698
                            string
    getChoiceLabelByValue(string $avalue)
        
    
    Retrieves the label of a choice by its value from the list of choices associated with that data item.
        at         line 754
                            void
    setChoices(array $choices)
        
    
    Sets the list of Choice Objects of this data item.
If the type of this data is "choice" or "multichoice", the list of choices allows the user to select the value of this data item.
        at         line 766
                            void
    addChoice(Choice $choice)
        
    
    Adds a Choice object in the list of choices of this data item.
        at         line 778
                            Choice|null
    getChoiceById(int $id)
        
    
    Retrieves a Choice object by its id in the list of choices of this data item.
        at         line 800
                            ChoiceSource|null
    getChoiceSource()
        
    
    Returns the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.
        at         line 812
                            void
    setChoiceSource(ChoiceSource $choiceSource)
        
    
    Sets the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.
        at         line 823
                            Table
    getTable()
        
    
    Returns the Table object associated with this data item if the type of this data is "table".
        at         line 835
                            void
    setTable(Table $table)
        
    
    Returns the Table object associated with this data item if the type of this data is "table".
        at         line 846
                            string
    getValue()
        
    
    Retrieves the current value of this data item
        at         line 865
                            string
    getPlainValue()
        
    
    Returns the current value of this data item in a string
        at         line 881
                            void
    setValue(string $value)
        
    
    Sets the current value of this data item
        at         line 914
                            int
    getInputStepId()
        
    
    Retrieves the id of the step where the user enters the value of this data item
Returns -1 if the value is never entered by the user.
        at         line 926
                            void
    setInputStepId(int $inputStepId)
        
    
    Sets the id of the step where the user enters the value of this data item
        at         line 937
                            array
    getRulesDependency()
        
    
    Returns the list of business rules that use this data item
        at         line 949
                            void
    setRulesDependency(array $rulesDependency)
        
    
    Sets the list of business rules that use this data item
        at         line 961
                            void
    addRuleDependency(int $ruleId)
        
    
    Adds a business rule id to the list of business rules that use this data item
        at         line 975
                            void
    removeRuleDependency(int $index)
        
    
    Removes a business rule id from the list of business rules that use this data item
        at         line 986
                            bool
    check()
        
    
    Checks the value of this data item according to its type
        at         line 1092
                        private    string
    replaceIdByDataLabel(array $matches)
        
    
    Returns the label of the data item whose identifier is the first element of the given array. The argument is an array because this method is the callback function of a preg_replace_callback.
If the data item is not found the given id prefixed by # is returned
        at         line 1106
                        private    string
    replaceByDataLabel(string $target)
        
    
    Replaces all data id (prefixed with #) by its label in the given text