Magrathea PHP 2

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"

Methods

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
ConfigFile

SetFile()

Sets the name of the config file

public SetFile(string $filePath) : ConfigFile
Parameters
$filePath : string

Name of the config file

Return values
ConfigFile

LoadFile()

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


        
On this page

Search results