Documentation

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
copyright

Cloudrexx AG

author

Thomas Wirz thomas.wirz@cloudrexx.com

subpackage

core_core

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

$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

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
see
static::offsetExists()
Return values
bool

get()

public get(string $key) : mixed
Parameters
$key : string
Tags
see
static::offsetGet()
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
inheritDoc
Return values
bool

offsetGet()

{@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_CONFIG_. Where is substituted by $prefix passed to the constructor of the object. Some examples follow. If $offset is 'cacheUserCacheMemcachedConfig' and object has been initialized with an empty $prefix, then the matching environment variable is: CLX_CONFIG_CACHE_USER_CACHE_MEMCACHED_CONFIG Or if $offset is 'host' and the object has been initialized with $prefix set to 'DB', then its matching environment variable is: CLX_DBCONFIG_HOST

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
inheritDoc

offsetUnset()

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Tags
inheritDoc

set()

public set(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Tags
see
static::offsetSet()

unset()

public unset(string $key) : void
Parameters
$key : string
Tags
see
static::offsetUnset()

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.


        
On this page

Search results