ConfigArray
extends ArrayObject
in package
Implementation of {@see \ArrayObject} with the addition that values will be fetched from the environment instead from a locally set key.
Tags
Table of Contents
Properties
- $config : array<string|int, mixed>
- $env : array<string|int, mixed>
- As getenv() is quite slow we cache the whole list of environment variables
- $prefix : string
Methods
- __construct() : mixed
- Construct a new Cloudrexx Config array
- exists() : bool
- get() : mixed
- getFromEnvVar() : mixed
- Retrieves the value of an environment variable corresponding to the given key.
- isSetByEnv() : bool
- Checks if an environment variable corresponding to the given key is set.
- offsetExists() : bool
- offsetGet() : string|int|null
- {@inheritDoc} If an matching system environment variable is set, then the value of that environment varible is returned instead. Any set value on this array will have no effect in that case.
- offsetSet() : void
- offsetUnset() : void
- set() : void
- unset() : void
- getEnvVarFormatForKey() : string
- Converts a given key into its environment variable format.
Properties
$config
protected
array<string|int, mixed>
$config
= []
$env
As getenv() is quite slow we cache the whole list of environment variables
protected
static array<string|int, mixed>
$env
= array()
List of environment variables
$prefix
protected
string
$prefix
= ''
Methods
__construct()
Construct a new Cloudrexx Config array
public
__construct([string $prefix = '' ]) : mixed
Parameters
- $prefix : string = ''
-
Use to set
exists()
public
exists(string $key) : bool
Parameters
- $key : string
Tags
Return values
boolget()
public
get(string $key) : mixed
Parameters
- $key : string
Tags
Attributes
- #[ReturnTypeWillChange]
getFromEnvVar()
Retrieves the value of an environment variable corresponding to the given key.
public
getFromEnvVar(string $key) : mixed
Parameters
- $key : string
-
The key to retrieve the value for.
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —The value of the environment variable, or null if not set.
isSetByEnv()
Checks if an environment variable corresponding to the given key is set.
public
isSetByEnv(string $key) : bool
Parameters
- $key : string
-
The key to check.
Return values
bool —True if the environment variable is set, false otherwise.
offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Tags
Return values
booloffsetGet()
{@inheritDoc} If an matching system environment variable is set, then the value of that environment varible is returned instead. Any set value on this array will have no effect in that case.
public
offsetGet(mixed $offset) : string|int|null
A matching system environment variable is defined as follows:
Each uppercase character in $offset (which should be in camelCase
notation) is prefixed by an underscore character, before converting the
resulting string all into uppercase and prefixing it with
CLX_
Parameters
- $offset : mixed
Attributes
- #[ReturnTypeWillChange]
Return values
string|int|null —Returned type depends on option identified by $offset
. If $offset
is undefined, then null
is returned. Important: this will change
in the future. Therefore you must not depend on that. Instead use
static::exists() to check for the existance of an option.
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
set()
public
set(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
Tags
unset()
public
unset(string $key) : void
Parameters
- $key : string
Tags
getEnvVarFormatForKey()
Converts a given key into its environment variable format.
protected
getEnvVarFormatForKey(string $key) : string
Parameters
- $key : string
-
The key to convert.
Return values
string —The formatted environment variable name.