|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2022-03-03 (6 months ago) ||Not enough user ratings||Total: 113 ||All time: 9,454 This week: 361|
This package can set and get configuration values from one object.
It provides an interface and an abstract class that can set and get several configuration values in the same object.
The package allows to set immutable values that can only be set once and cannot be changed after the initial value assignment.
It also allows to switch a set of boolean values all at once.
|Every application needs to manage configuration values used in different application parts.
Experienced developers usually work on the application in a development environment with specific configuration values adequate for that environment.
In the production environment, applications may use different configuration values in the same application code more suited to the production environment.
This package provides a practical configuration class that allows setting configuration values only once.
This feature is helpful in situations where configuration values will have fixed values that applications should not change.
Such situations are precisely the case when there are application-wide configuration values set only once during application initialization.
The possibility of setting multiple boolean configuration values is also helpful to reduce the necessary code to set different configuration settings assigned to the same boolean value.
A lot of scripts and packages in modern PHP demand one or more configuration classes. Mostly, those are a set of properties that can be set, changed or retrieved. However, some of the configurations have a peculiar behaviour - such as boolean properties. Also, we want some of the settings to be manageable in the future - for some other we want values to remain immutable after a first setup.
There are plenty of proposed interfaces for that - what is different in this Configurable interface are two methods in particular: immutable() and switch().
This packages brings a Configurable interface and an abstract that comprises a very objective implementation of that. Shortly, we are also going to provide a trait with the same function.
Equipped with standard methods for this kind of class, such as get(), set() and getDefaults (this last retrieving all properties as they are in that moment), both the interface and the abstract propose two new methods:
The immutable() method
The immutable method allows a property to be set or redefined (if the class already brings any default value) just once. After that, the property key is stored in a private variable and any new attempt of setting new values will be ignored.
The switch() method
This method provides a quick and simpler way of changing one or more boolean properties. As the name suggests, any property set as FALSE will be switched to TRUE, so as it makes all TRUE values to become FALSE.
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.