DataType
in package
A DataType is the smallest entity of Data.
Every value of an \VeruA\DataObjects\DataObject is represented as such.
Table of Contents
- $validators : array<string|int, callable>
- $value : mixed
- __construct() : mixed
- The constructor is normally called from the DataObject when instatiated.
- __toString() : string
- Make sure to overwrite this method in the implementations
- equals() : mixed
- Compares the internal value with the $compare argument
- in() : mixed
- Stores the $value applying the input filters
- out() : mixed
- Returns the $value applying the output filters
- raw() : mixed
- Returns the value without processing it
- validate() : true
- Runs all registered validators
- value() : mixed
- Returns the internal value
Properties
$validators
protected
array<string|int, callable>
$validators
= []
$value
protected
mixed
$value
Methods
__construct()
The constructor is normally called from the DataObject when instatiated.
public
__construct([mixde $value = null ][, array<string|int, mixed> $props = [] ]) : mixed
Inside the constructor the validator callables are generated and saved in the $validators member
When a concrete implementation of DataType is written, make sure to call the parent constructor
to have the validators in place
Parameters
- $value : mixde = null
- $props : array<string|int, mixed> = []
-
The properties for the standard validators
Return values
mixed —__toString()
Make sure to overwrite this method in the implementations
public
__toString() : string
Return values
string —The string representation of the DataType
equals()
Compares the internal value with the $compare argument
public
equals(DataType|mixed $compare) : mixed
Remember that you get a DataObject when using the DataObjects values, thus comparison can have
undesired results, use the equals method to compare DataTypes
This has to be overwritten in the descendants to get the desired comparison behaviour
Parameters
- $compare : DataType|mixed
-
The value to be compared
Return values
mixed —in()
Stores the $value applying the input filters
public
in(mixed $value) : mixed
This method should be overwritten in the concrete implementation
Parameters
- $value : mixed
Tags
Return values
mixed —out()
Returns the $value applying the output filters
public
out() : mixed
This method should be overwritten in the concrete implementation
Tags
Return values
mixed —raw()
Returns the value without processing it
public
raw() : mixed
Tags
Return values
mixed —validate()
Runs all registered validators
public
validate() : true
Tags
Return values
true —if validations was succsessful
value()
Returns the internal value
public
value() : mixed