SET()
, GET()
and MOD()
which are applied synergetically. This means that for any defined value to be
properly managed, there has to be a top level to down level relationship between values. Values that are defined at top level can then be
handled or managed in a manner desired by the developer. This system can be mostly used to keep track of specific value properties. For example,
while php variables may be updated as desired along the code, setter values can be prevented from being updated at a low level if certain conditions are not met.
This system also makes it easier to detect when a value which must not change is being modified more than once or when a function or class is running more than once.
SET()
method has to be called at the top level. This method takes two arguments. The syntax is shown below:
SETTER::SET(KEY, VALUE, SECURE)
where:
KEY : Protected Key
VALUE : Key's value
SECURE : secure hash/string
KEY
above is the value (or variable) that needs to be protected while the VALUE
is the
content of that KEY
. The SECURE
defines the security level of the KEY
. If SECURE
is set as TRUE
, then the KEY
defined cannot be updated or modified after it has been defined.
This turns the KEY
to a read-only key. Any attempt to use SETTER::MOD()
to modify the key's value,
an error will be thrown preventing such activity. However, if the SECURE
value is a non-empty string, then it is assumed to be
a secure hash string. Whenever secure hash strings are used, then such hash must be provided by the SETTER::MOD()
in order
for the value to be updated. If the MOD()
(i.e modifier) hash does not match the one used to secure the KEY
,
then an error is thrown. Also, whenever a new value is defined, it cannot be redefined using SETTER::SET()
again.
Instead, the SETTER::MOD()
must be called.
SETTER::MOD()
method has to be called.
If this method is called before a value is set, an error will be thrown.
It takes three argument and the syntax is shown below:
SETTER::MOD(KEY, VALUE, HASH)
where:
KEY : Protected Key
VALUE : Key's new value
HASH : secure hash string
KEY
above is the value (or variable) that needs to be modified or updated while the VALUE
is the
new content of that KEY
. The HASH
defines the secure hash string used to set the key, if defined.
This means that whenever secure hash strings are used to lock a value when defined using SETTER::SET()
, then such
hash must be provided by the SETTER::MOD()
in order
for the value to be updated. If the MOD()
(i.e modifier) hash does not match the one used to secure the KEY
,
then an error is thrown.
SETTER::GET()
method has to be called.
If this method is called before a value is set, an error will be thrown.
This method takes two argument. The syntax is shown below:
SETTER::GET(KEY, HASH)
where:
KEY : Protected Key
HASH : secure hash string
KEY
above is the value (or variable) whose value needs to be fetched. Whenever a key is secured with an hash, then the
HASH
string must be provided before the value of that key can be obtained. If the value of the HASH
does not match,
an error is thrown. Also, if a KEY is not secured in SET()
but HASH
was provided in GET()
, although the value
will be returned, an error will still be triggered discouraging such activity.
SETTER::SET()
if the key has already been defined, we have to check if a key already exists
by using the method SETTER::EXIST()
. This will only return true if a key already exists. The usage is shown below: if( !SETTER::EXISTS('key') ) { SETTER::SET('key', 'value'); }
SET()
and GET()
functions. Although, we don't have
any MOD()
helper function, the SET()
function is build to handle updates in the manner SETTER::MOD()
will handle it. The SET()
function naturally checks if a varible is updateable or not previously set before setting them and it takes the same parameter as the SETTER::SET()
or SETTER::MOD()
methods. This obviously save more time. The GET()
method obtains the value of a previously defined key. SET('NAME 1', 'Felix'); SET('NAME 2', 'Rolland', true); SET('NAME 3', 'Charley', 'hash123'); GET('NAME 1') // returns Felix GET('NAME 1', 'hash234') // returns Felix, but triggers error GET('NAME 2') // returns Rolland GET('NAME 2', 'hash234') // returns Rolland, but triggers error GET('NAME 3') // invalid hash triggers error GET('NAME 3', 'hash123') // returns Charley GET('NAME 3', 'hash234') // invalid hash triggers error
SET
and GET
functions work while the example below
explains how modifications work.
SET('NAME 1', 'Felix'); SET('NAME 2', 'Rolland', true); SET('NAME 3', 'Charley', 'hash123'); SET('NAME 1', 'New Felix') // allowed SET('NAME 2', 'New Rolland') // denied (read-only) SET('NAME 3', 'New Charley', 'hash123') // allowed (valid hash) SET('NAME 3') // denied (invalid hash) SET('NAME 3', 'hash234') // denied (invalid hash)