Magrathea PHP 2

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

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|null

GetAvailableEnvironments()

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
todo

exception 704 on key does not exists

Return values
array<string|int, mixed>|string

GetConfigFromDefault()

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|null

GetConfigSection()

`$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
todo

exception 704 on key does not exists

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

SetConfig()

sets config

public SetConfig(array<string|int, mixed> $c) : Config
Parameters
$c : array<string|int, mixed>

configuration

Return values
Config

SetConfigFile()

set name of config file

public SetConfigFile(string $f) : Config
Parameters
$f : string

name of file

Return values
Config

SetEnvironment()

This function will set the environment for future operations

public SetEnvironment(mixed $e) : Config
Parameters
$e : mixed
Return values
Config

SetInstance()

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

__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
Tags
throws
MagratheaConfigException

for file not found

Return values
Config

        
On this page

Search results