Index Documentation

Config
in

Provides a common interface for configuration providers.

Table of Contents

Methods

getAllValueInfos()  : array<string|int, ConfigValueInfo>
Lists all value informations from this configuration.
getArray()  : array<string|int, mixed>
Gets an array value.
getBoolean()  : bool
Gets a single boolean value.
getFloat()  : float
Gets a single floating point value.
getInteger()  : int
Gets a single integer value.
getSeparator()  : string
Gets the separator character used for scoping.
getString()  : string
Gets a single string value.
getValueInfo()  : ConfigValueInfo|null
Gets value information for a single item.
getValueInfos()  : array<string|int, ConfigValueInfo>
Gets value informations for one or more items.
getValues()  : array<string, mixed>
Gets multiple values of varying types at once.
hasValues()  : bool
Checks if configurations contains given names.
removeValues()  : void
Removes values with given names from the configuration, if writable.
scopeTo()  : Config
Creates a scoped configuration instance that prepends a prefix to all names.
setArray()  : void
Sets an array value.
setBoolean()  : void
Sets a single boolean value.
setFloat()  : void
Sets a single floating point value.
setInteger()  : void
Sets a single integer value.
setString()  : void
Sets a single string value.
setValues()  : void
Sets multiple values at once using an associative array.

Methods

getAllValueInfos()

Lists all value informations from this configuration.

public getAllValueInfos([int $range = 0 ][, int $offset = 0 ]) : array<string|int, ConfigValueInfo>
Parameters
$range : int = 0

Amount of items to take, 0 for all. Must be a positive integer.

$offset : int = 0

Amount of items to skip. Must be a positive integer. Has no effect if $range is 0.

Tags
throws
InvalidArgumentException

If $range or $offset are negative.

Return values
array<string|int, ConfigValueInfo>

Configuration value infos.

getArray()

Gets an array value.

public getArray(string $name[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
$name : string

Name of the value to fetch.

$default : array<string|int, mixed> = []

Default value to fall back on if the value is not present.

Return values
array<string|int, mixed>

Configuration value for $name.

getBoolean()

Gets a single boolean value.

public getBoolean(string $name[, bool $default = false ]) : bool
Parameters
$name : string

Name of the value to fetch.

$default : bool = false

Default value to fall back on if the value is not present.

Return values
bool

Configuration value for $name.

getFloat()

Gets a single floating point value.

public getFloat(string $name[, float $default = 0 ]) : float
Parameters
$name : string

Name of the value to fetch.

$default : float = 0

Default value to fall back on if the value is not present.

Return values
float

Configuration value for $name.

getInteger()

Gets a single integer value.

public getInteger(string $name[, int $default = 0 ]) : int
Parameters
$name : string

Name of the value to fetch.

$default : int = 0

Default value to fall back on if the value is not present.

Return values
int

Configuration value for $name.

getSeparator()

Gets the separator character used for scoping.

public getSeparator() : string
Return values
string

Separator character.

getString()

Gets a single string value.

public getString(string $name[, string $default = '' ]) : string
Parameters
$name : string

Name of the value to fetch.

$default : string = ''

Default value to fall back on if the value is not present.

Return values
string

Configuration value for $name.

getValueInfo()

Gets value information for a single item.

public getValueInfo(string $name) : ConfigValueInfo|null
Parameters
$name : string

Name or names to retrieve.

Return values
ConfigValueInfo|null

Value information, or null if not present.

getValueInfos()

Gets value informations for one or more items.

public getValueInfos(string|array<string|int, string> $names) : array<string|int, ConfigValueInfo>
Parameters
$names : string|array<string|int, string>

Name or names to retrieve.

Return values
array<string|int, ConfigValueInfo>

Array with value informations.

getValues()

Gets multiple values of varying types at once.

public getValues(array<string|int, string|array<string|int, string>> $specs) : array<string, mixed>

The format of a $specs entry can be one of the following: If the entry is a string:

  • The name of a value: 'value_name'
  • The name of a value followed by a requested type, separated by a colon: 'value_name:s', 'value_name:i', 'value_name:a' If the entry is an array, all except [0] are optional:
  • [0] follows to same format as the above described string
  • [1] is the default value to fall back on, MUST be the same type as the one specified in [0].
  • [2] is an alternative key for the output array.

Available types are: :s - string :a - array :i - integer :b - boolean :f - float :d - float

Parameters
$specs : array<string|int, string|array<string|int, string>>

Specification of what items to grab.

Tags
throws
InvalidArgumentException

If $specs is malformed.

Return values
array<string, mixed>

An associative array containing the retrieved values.

hasValues()

Checks if configurations contains given names.

public hasValues(string|array<string|int, string> $names) : bool

An empty $names list will always return true.

Parameters
$names : string|array<string|int, string>

Name or names to check for.

Return values
bool

Whether all given names are present or not.

removeValues()

Removes values with given names from the configuration, if writable.

public removeValues(string|array<string|int, string> $names) : void
Parameters
$names : string|array<string|int, string>

Name or names to remove.

Tags
throws
RuntimeException

If the configuration is read only.

scopeTo()

Creates a scoped configuration instance that prepends a prefix to all names.

public scopeTo(string ...$prefix) : Config
Parameters
$prefix : string
Return values
Config

A scoped configuration instance.

setArray()

Sets an array value.

public setArray(string $name, array<string|int, mixed> $value) : void
Parameters
$name : string

Name of the value to save.

$value : array<string|int, mixed>

Value to save.

setBoolean()

Sets a single boolean value.

public setBoolean(string $name, bool $value) : void
Parameters
$name : string

Name of the value to save.

$value : bool

Value to save.

setFloat()

Sets a single floating point value.

public setFloat(string $name, float $value) : void
Parameters
$name : string

Name of the value to save.

$value : float

Value to save.

setInteger()

Sets a single integer value.

public setInteger(string $name, int $value) : void
Parameters
$name : string

Name of the value to save.

$value : int

Value to save.

setString()

Sets a single string value.

public setString(string $name, string $value) : void
Parameters
$name : string

Name of the value to save.

$value : string

Value to save.

setValues()

Sets multiple values at once using an associative array.

public setValues(array<string, mixed> $values) : void
Parameters
$values : array<string, mixed>

Values to save.

Tags
throws
InvalidArgumentException

If $values is malformed.

throws
RuntimeException

If the configuration is read only.


        
On this page

Search results