Config
extends Singleton
in package
This class will provide you the quickest access possible to the magrathea.conf config file.
Table of Contents
Properties
- $instance : array<string|int, mixed>|null
- $configFile : mixed
- $configs : mixed
- $environment : mixed
- $path : mixed
Methods
- __wakeup() : mixed
- Get() : string|int|null
- Alias for GetConfigFromDefault
- GetAvailableEnvironments() : array<string|int, mixed>
- returns an array with available environments
- GetConfig() : array<string|int, mixed>|string
- `$config_name` can be called to get a parameter from inside a section of the config file. To achieve this, you should use a slash (/) to separate the section from the property.
- GetConfigFromDefault() : string|int|null
- This function will get the $config_name property from `magrathea.conf`.
- GetConfigSection() : array<string|int, mixed>
- `$section_name` is the name of the section that will be returned as an array.
- GetEnvironment() : string
- This function will return the environment being used in the project.
- GetFilePath() : string
- Getst file path
- GetPath() : string
- Gets file path
- Instance() : static|Singleton
- MockClass() : static|Singleton
- SetConfig() : Config
- sets config
- SetConfigFile() : Config
- set name of config file
- SetEnvironment() : Config
- This function will set the environment for future operations
- SetInstance() : mixed
- SetPath() : Config
- set path for config file
- __clone() : mixed
- __construct() : mixed
- LoadFile() : Config
- Function for openning the file specified in `$this->config_file_name` actually, it works checking if file exists and throwing an error if don't.
Properties
$instance
protected
static array<string|int, mixed>|null
$instance
= []
$configFile
private
mixed
$configFile
= "magrathea.conf"
$configs
private
mixed
$configs
= null
$environment
private
mixed
$environment
= null
$path
private
mixed
$path
= "configs"
Methods
__wakeup()
public
final __wakeup() : mixed
Get()
Alias for GetConfigFromDefault
public
Get(string $config_name) : string|int|null
Parameters
- $config_name : string
-
Item to be returned from the
magrathea.conf
.
Return values
string|int|nullGetAvailableEnvironments()
returns an array with available environments
public
GetAvailableEnvironments() : array<string|int, mixed>
Return values
array<string|int, mixed> —environments list
GetConfig()
`$config_name` can be called to get a parameter from inside a section of the config file. To achieve this, you should use a slash (/) to separate the section from the property.
public
GetConfig([string $config_name = "" ]) : array<string|int, mixed>|string
If the slash is not used, the function will return the property only if it's on the root.
If $config_name
is a section name, the function will return the full section as an Array.
If $config_name
is empty, the function will return the full config as an Array (not recommended!).
Parameters
- $config_name : string = ""
-
Item to be returned from the
magrathea.conf
.
Tags
Return values
array<string|int, mixed>|stringGetConfigFromDefault()
This function will get the $config_name property from `magrathea.conf`.
public
GetConfigFromDefault(string $config_name[, bool $throwable = false ]) : string|int|null
It will get from the section defined on general/use_environment
.
Parameters
- $config_name : string
-
Item to be returned from the
magrathea.conf
. - $throwable : bool = false
-
should this function throw an exception if array key don't exist?
Return values
string|int|nullGetConfigSection()
`$section_name` is the name of the section that will be returned as an array.
public
GetConfigSection(string $section_name) : array<string|int, mixed>
Parameters
- $section_name : string
-
Name of the section to be returned from the
magrathea.conf
.
Tags
Return values
array<string|int, mixed>GetEnvironment()
This function will return the environment being used in the project.
public
GetEnvironment() : string
The environment is defined in general/use_environment
property and can be defined in the magrathea.conf
file.
Return values
string —Environment name
GetFilePath()
Getst file path
public
GetFilePath() : string
Return values
string —file path
GetPath()
Gets file path
public
GetPath() : string
Return values
string —path of the config file
Instance()
public
static Instance() : static|Singleton
Return values
static|SingletonMockClass()
public
static MockClass(mixed $mocker) : static|Singleton
Parameters
- $mocker : mixed
Return values
static|SingletonSetConfig()
sets config
public
SetConfig(array<string|int, mixed> $c) : Config
Parameters
- $c : array<string|int, mixed>
-
configuration
Return values
ConfigSetConfigFile()
set name of config file
public
SetConfigFile(string $f) : Config
Parameters
- $f : string
-
name of file
Return values
ConfigSetEnvironment()
This function will set the environment for future operations
public
SetEnvironment(mixed $e) : Config
Parameters
- $e : mixed
Return values
ConfigSetInstance()
public
SetInstance(mixed $inst) : mixed
Parameters
- $inst : mixed
SetPath()
set path for config file
public
SetPath(string $p) : Config
Parameters
- $p : string
-
Path to the file
Return values
Config__clone()
protected
final __clone() : mixed
__construct()
private
final __construct() : mixed
LoadFile()
Function for openning the file specified in `$this->config_file_name` actually, it works checking if file exists and throwing an error if don't.
private
LoadFile() : Config