ConfigMaker
Config Maker Trait Adds configuration based methods to a class
Tags
Table of Contents
- $configPath : string
- getConfigPath() : string
- Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.
- guessConfigPath() : string
- Guess the package path for the called class.
- guessConfigPathFrom() : string
- Guess the package path from a specified class.
- makeConfig() : array<string|int, mixed>|stdClass
- Reads the contents of the supplied file and applies it to this object.
- makeConfigFromArray() : stdClass
- Makes a config object from an array, making the first level keys properties of a new object.
- mergeConfig() : stdClass
- Merges two configuration sources, either prepared or not, and returns them as a single configuration object.
Properties
$configPath
protected
string
$configPath
Specifies a path to the config directory.
Methods
getConfigPath()
Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.
public
getConfigPath(string $fileName[, mixed $configPath = null ]) : string
Parameters
- $fileName : string
-
File to load.
- $configPath : mixed = null
-
Explicitly define a config path.
Return values
string —Full path to the config file.
guessConfigPath()
Guess the package path for the called class.
public
guessConfigPath([string $suffix = '' ]) : string
Parameters
- $suffix : string = ''
-
An extra path to attach to the end
Return values
string —guessConfigPathFrom()
Guess the package path from a specified class.
public
guessConfigPathFrom(string $class[, string $suffix = '' ]) : string
Parameters
- $class : string
-
Class to guess path from.
- $suffix : string = ''
-
An extra path to attach to the end
Return values
string —makeConfig()
Reads the contents of the supplied file and applies it to this object.
public
makeConfig([array<string|int, mixed> $configFile = [] ][, array<string|int, mixed> $requiredConfig = [] ]) : array<string|int, mixed>|stdClass
Parameters
- $configFile : array<string|int, mixed> = []
- $requiredConfig : array<string|int, mixed> = []
Return values
array<string|int, mixed>|stdClass —makeConfigFromArray()
Makes a config object from an array, making the first level keys properties of a new object.
public
makeConfigFromArray([array<string|int, mixed> $configArray = [] ]) : stdClass
Parameters
- $configArray : array<string|int, mixed> = []
-
Config array.
Return values
stdClass —The config object
mergeConfig()
Merges two configuration sources, either prepared or not, and returns them as a single configuration object.
public
mergeConfig(mixed $configA, mixed $configB) : stdClass
Parameters
- $configA : mixed
- $configB : mixed
Return values
stdClass —The config object