\Gishiki\CoreConfiguration

Represents the application configuration.

Summary

Methods
Properties
Constants
__construct()
serialize()
deserialize()
__toString()
loadFromFile()
No public properties found
JSON
XML
YAML
No protected methods found
No protected properties found
N/A
completeSettings()
getValueFromEnvironment()
No private properties found
N/A

Constants

JSON

JSON

XML

XML

YAML

YAML

Methods

__construct()

__construct(array  $data = array()) 

Load Application configuration.

Load configuration from the given data, read documentation for more.

Parameters

array $data

configuration data

serialize()

serialize(integer  $format = self::JSON) : string

Serialize the current data collection.

Parameters

integer $format

an integer representing one of the allowed formats

Throws

\InvalidArgumentException

the serialization format is invalid

\Gishiki\Algorithms\Collections\SerializationException

the error occurred while serializing the collection in json format

Returns

string —

the collection serialized

deserialize()

deserialize(string|array|\Gishiki\Algorithms\Collections\CollectionInterface  $message, integer  $format = self::JSON) : \Gishiki\Algorithms\Collections\SerializableCollection

Deserialize the given data collection and create a serializable data collection.

Parameters

string|array|\Gishiki\Algorithms\Collections\CollectionInterface $message

the string containing the serialized data or the array of data

integer $format

an integer representing one of the allowed formats

Throws

\Gishiki\Algorithms\Collections\DeserializationException

the error preventing the data deserialization

Returns

\Gishiki\Algorithms\Collections\SerializableCollection

the deserialization result

__toString()

__toString() : string

Get the serialization result using the default format.

Returns

string —

the serialization result

loadFromFile()

loadFromFile(string|null  $filename = null) : \Gishiki\Core\Configuration

Parse the given configuration file.

Read the given file in JSON format and produce a Configuration from it, where placeholders have been replaced with correct values.

Parameters

string|null $filename

the name of the file to be used or null for default

Throws

\Gishiki\Core\Exception

the given file cannot be found

Returns

\Gishiki\Core\Configuration

the parsed configuration

completeSettings()

completeSettings(array  $collection) : array

Complete the configuration resolving every value placeholder.

Read more on documentation.

Parameters

array $collection

the configuration to be finished

Returns

array —

the completed configuration

getValueFromEnvironment()

getValueFromEnvironment(string  $key) : string

Get the value of an environment variable from its name.

Parameters

string $key

the name of environment variable

Returns

string —

the value of the environment variable