A general key-value store for user-supplied settings.
A \FeaturePhp\ProductLine\ProductLine and its dependencies can be configured in many ways by the user. The settings class provides a uniform interface for checking, reading and writing individual settings. For a description of the actual settings, see \FeaturePhp\ProductLine\Settings.
| package | Default |
|---|
__construct(array $cfg, string $directory = ".")
The directory may be used to resolve relative paths in the settings.
arraya plain settings array
stringthe directory the settings apply to
fromArray(array $cfg, string $directory = ".")
arraya plain settings array
stringthe directory the settings apply to
fromFile(string $fileName) : \FeaturePhp\Settings
string
\FeaturePhp\SettingsfromString(string $json, string $directory = ".") : \FeaturePhp\Settings
string
stringthe directory the settings apply to
\FeaturePhp\Settingsget() : mixed
A setting path can be supplied variadically.
mixedgetDirectory() : string
stringgetIn(array $cfg) : mixed
A setting path can be supplied variadically.
array
mixedgetInstance(string|array|boolean $object, string $klass) : \FeaturePhp\$class
If a string is given, the class is instantiated from a file. If an array("data" => ...) is given, the class is instantiated from a string. If another array is given, the class is instantiated from that array. If true is given, the class is instantiated from an empty array.
stringarrayboolean
string
\FeaturePhp\$classgetOptional(mixed $defaultValue) : mixed
A setting path can be supplied variadically.
mixed
mixedgetPath(string $path) : string
string
stringgetWith(string $key, callable $predicate) : mixed
Throws \FeaturePhp\InvalidSettingsException if the predicate fails.
string
callable
mixedinDirectory(string $directory)
stringthe directory the settings apply to
has(string $key, array $cfg = null) : boolean
If no settings array is given, the internal settings array is assumed.
string
array
booleanset(string $key, mixed $value)
A setting path can be supplied variadically.
string
mixed
setOptional(string $key, mixed $value)
string
mixed
_get(array $cfg) : mixed
A setting path can be supplied variadically.
array
mixed_set(array $cfg, array $args)
array
arraya setting path followed by the setting's new value
$cfg : array