ConfigFile
in package
Magrathea Config loads and saves information in config files.
Table of Contents
Properties
- $configFileName : mixed
- $configs : mixed
- $path : mixed
Methods
- __construct() : mixed
- CreateFileIfNotExists() : bool
- Creates the configuration file if it doesn't exists. And saves it.
- GetConfig() : string|int|array<string|int, mixed>
- Gets configuration
- GetConfigSection() : array<string|int, mixed>
- Gets a full config section
- GetPath() : string
- gets config file path
- Save() : bool
- Saves the config file
- SetConfig() : ConfigFile
- Sets the config information
- SetFile() : ConfigFile
- Sets the name of the config file
- SetPath() : ConfigFile
- Set the path to the confi file
- LoadFile() : mixed
- Loads the configuration file
- SaveValueOnConfig() : string
- Sets the correct format for the value
Properties
$configFileName
private
mixed
$configFileName
= "magrathea.conf"
$configs
private
mixed
$configs
= null
$path
private
mixed
$path
= __DIR__
Methods
__construct()
public
__construct() : mixed
CreateFileIfNotExists()
Creates the configuration file if it doesn't exists. And saves it.
public
CreateFileIfNotExists() : bool
Return values
bool —True if the file exists; Return of Save()
function if it doesn't
GetConfig()
Gets configuration
public
GetConfig([string $config_name = "" ]) : string|int|array<string|int, mixed>
Parameters
- $config_name : string = ""
-
Configuration to be got. If empty, returns all the configuration into the file If an acceptable config name, returns its value
Return values
string|int|array<string|int, mixed> —If $config_name
is empty, returns all the configuration. Otherwise,
@todo exception 704 on key does not exists
GetConfigSection()
Gets a full config section
public
GetConfigSection(string $section_name) : array<string|int, mixed>
Parameters
- $section_name : string
-
Name of the section to be shown
Return values
array<string|int, mixed> —All the values of the given section @todo exception 704 on key does not exists
GetPath()
gets config file path
public
GetPath() : string
Return values
string —full path
Save()
Saves the config file
public
Save([bool $save_sections = true ]) : bool
Parameters
- $save_sections : bool = true
-
A flag indicating if the sections should be saved also. Default:
true
Return values
bool —True if the saved succesfully. False if got any error in the process
SetConfig()
Sets the config information
public
SetConfig(array<string|int, mixed> $c) : ConfigFile
Parameters
- $c : array<string|int, mixed>
-
Config to be set
Return values
ConfigFileSetFile()
Sets the name of the config file
public
SetFile(string $filePath) : ConfigFile
Parameters
- $filePath : string
-
Name of the config file
Return values
ConfigFileSetPath()
Set the path to the confi file
public
SetPath(string $p) : ConfigFile
Parameters
- $p : string
-
Path to be set
Return values
ConfigFileLoadFile()
Loads the configuration file
private
LoadFile() : mixed
SaveValueOnConfig()
Sets the correct format for the value
private
SaveValueOnConfig(any $value) : string
Parameters
- $value : any
-
to be saved
Return values
string —formatted value to be saved on config file