Index Documentation

FsConfig
in package
implements Config uses ImmutableConfigTrait, GetValueInfoTrait, GetValuesTrait

Provides a configuration in string based format.

Table of Contents

Interfaces

Config
Provides a common interface for configuration providers.

Methods

__construct()  : mixed
fromFile()  : FsConfig
Creates an instance of FsConfig from a file.
fromLines()  : FsConfig
Creates an instance of FsConfig from an array of lines.
fromStream()  : FsConfig
Creates an instance of FsConfig from a readable stream.
fromString()  : FsConfig
Creates an instance of FsConfig from a string.
getAllValueInfos()  : array<string|int, ConfigValueInfo>
Lists all value informations from this configuration.
getArray()  : array<string|int, mixed>
getBoolean()  : bool
getFloat()  : float
getInteger()  : int
getSeparator()  : string
Gets the separator character used for scoping.
getString()  : string
getValueInfo()  : ConfigValueInfo|null
getValueInfos()  : array<string|int, ConfigValueInfo>
Gets value informations for one or more items.
getValues()  : array<string, mixed>
Format described in {@see Config::getValues}.
hasValues()  : bool
Checks if configurations contains given names.
removeValues()  : void
scopeTo()  : Config
Creates a scoped configuration instance that prepends a prefix to all names.
setArray()  : void
setBoolean()  : void
setFloat()  : void
setInteger()  : void
setString()  : void
setValues()  : void

Methods

fromFile()

Creates an instance of FsConfig from a file.

public static fromFile(string $path) : FsConfig
Parameters
$path : string

Config file path.

Tags
throws
InvalidArgumentException

If $path does not exist or could not be opened.

Return values
FsConfig

fromLines()

Creates an instance of FsConfig from an array of lines.

public static fromLines(array<string|int, string> $lines) : FsConfig
Parameters
$lines : array<string|int, string>

Config lines.

Return values
FsConfig

fromStream()

Creates an instance of FsConfig from a readable stream.

public static fromStream(resource $stream) : FsConfig
Parameters
$stream : resource

Config file stream.

Tags
throws
InvalidArgumentException

If $stream is not a .

Return values
FsConfig

fromString()

Creates an instance of FsConfig from a string.

public static fromString(string $lines[, non-empty-string $newLine = " " ]) : FsConfig
Parameters
$lines : string

Config lines.

$newLine : non-empty-string = " "

Line separator character.

Return values
FsConfig

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.

Return values
array<string|int, ConfigValueInfo>

Configuration value infos.

getArray()

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

getBoolean()

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

getFloat()

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

getInteger()

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

getSeparator()

Gets the separator character used for scoping.

public getSeparator() : string
Return values
string

Separator character.

getString()

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

getValueInfos()

Gets value informations for one or more items.

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

Name or names to retrieve.

Return values
array<string|int, ConfigValueInfo>

Array with value informations.

getValues()

Format described in {@see Config::getValues}.

public getValues(array<string|int, string|array<string|int, string>> $specs) : array<string, mixed>
Parameters
$specs : array<string|int, string|array<string|int, string>>
Tags
throws
InvalidArgumentException

If $specs contains an invalid entry.

Return values
array<string, mixed>

hasValues()

Checks if configurations contains given names.

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

An empty $names list will always return true.

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

Name or names to check for.

Return values
bool

Whether all given names are present or not.

removeValues()

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

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()

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

setBoolean()

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

setFloat()

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

setInteger()

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

setString()

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

setValues()

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

        
On this page

Search results