PHP Класс Gush\Config

Configuration is stored per type: system and local, and is always merged into the "all" type which is only used for getting and not setting. Note that the Config class does not check if the provided directories are valid or even exist. This class is only for holding configuration.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( $homedir, array $config = [], $localHome = null, array $localConfig = [] )
get ( string | string[] $keys, string $type = self::CONFIG_ALL, string | integer | float | boolean | array $default = null ) : string | integer | float | boolean | array Returns a config value.
getFirstNotNull ( array $keys, string $type = self::CONFIG_ALL, string | integer | float | boolean | array $default = null ) : string | integer | float | boolean | array Returns the first none-null configuration value.
has ( string $key, string $type = self::CONFIG_ALL ) : boolean Checks whether the config exists.
merge ( array $config, $type ) Merges new config values with the existing ones (overriding).
set ( string $key, string | integer | float | boolean | array $value, string $type ) : Config Merges new config values with the existing ones (overriding).
toArray ( string $type = self::CONFIG_ALL ) : array Get the configuration is as array.

Приватные методы

Метод Описание
guardConfigSlot ( string $type ) Guard the configuration slot is valid.

Описание методов

__construct() публичный Метод

public __construct ( $homedir, array $config = [], $localHome = null, array $localConfig = [] )
$config array
$localConfig array

get() публичный Метод

Returns a config value.
public get ( string | string[] $keys, string $type = self::CONFIG_ALL, string | integer | float | boolean | array $default = null ) : string | integer | float | boolean | array
$keys string | string[] Single level key like 'adapters' or array-path like ['adapters', 'github']
$type string Either Config::CONFIG_SYSTEM Config::CONFIG_LOCAL or Config::CONFIG_ALL
$default string | integer | float | boolean | array Default value to use when no config is found (null)
Результат string | integer | float | boolean | array

getFirstNotNull() публичный Метод

Returns the first none-null configuration value.
public getFirstNotNull ( array $keys, string $type = self::CONFIG_ALL, string | integer | float | boolean | array $default = null ) : string | integer | float | boolean | array
$keys array Array of single level keys like "adapters" or property-path "[adapters][github]" to check
$type string Either Config::CONFIG_SYSTEM Config::CONFIG_LOCAL or Config::CONFIG_ALL
$default string | integer | float | boolean | array Default value to use when no config is found (null)
Результат string | integer | float | boolean | array

has() публичный Метод

Note. A value with null is considered undefined.
public has ( string $key, string $type = self::CONFIG_ALL ) : boolean
$key string Single level key like "adapters" or property-path "[adapters][github]"
$type string Either Config::CONFIG_SYSTEM Config::CONFIG_LOCAL or Config::CONFIG_ALL
Результат boolean

merge() публичный Метод

Merges new config values with the existing ones (overriding).
public merge ( array $config, $type )
$config array

set() публичный Метод

This can only store a single-key level like "adapters" but not "[adapters][github]".
public set ( string $key, string | integer | float | boolean | array $value, string $type ) : Config
$key string Single level config key
$value string | integer | float | boolean | array Value to store
$type string Either Config::CONFIG_SYSTEM or Config::CONFIG_LOCAL
Результат Config

toArray() публичный Метод

Get the configuration is as array.
public toArray ( string $type = self::CONFIG_ALL ) : array
$type string Either Config::CONFIG_SYSTEM Config::CONFIG_LOCAL or Config::CONFIG_ALL
Результат array