AppConfig
in package
The AppConfig class
Store application configuration in a file
Tags
Table of Contents
Constants
- ALL_TYPES = [self::TYPE_STRING, self::TYPE_BOOLEAN, self::TYPE_LONG_TEXT]
- DEFAULT_TYPE = self::TYPE_STRING
- TYPE_BOOLEAN = 'boolean'
- TYPE_LONG_TEXT = 'text'
- TYPE_STRING = 'simple'
- VERSION = '2'
Properties
- $changed : bool
- $data : array<string|int, mixed>
- $instance : static
- $meta : array<string|int, mixed>
- $path : string|null
Methods
- __destruct() : mixed
- Destructor auto save configuration
- asArray() : array<string|int, mixed>
- Get it as array
- get() : mixed|null
- Get value by key
- getData() : array<string|int, mixed>
- Get the data
- getInstance() : AppConfig
- Get main instance
- getPath() : string|null
- Get the path
- getType() : string
- Get the type of $key
- has() : bool
- Test if config has $key
- instance() : AppConfig
- Alias for getInstance()
- load() : void
- Load config from filesystem
- loadSmartly() : void
- Load config if it exists
- preset() : bool
- Set $key if not yet set
- remove() : void
- Test if config has $key
- save() : int
- Save config into the filesystem
- set() : bool
- Set the $value of $key
- setData() : static
- Set the data
- setPath() : static
- Set the path
- __construct() : mixed
- AppConfig constructor
Constants
ALL_TYPES
public
mixed
ALL_TYPES
= [self::TYPE_STRING, self::TYPE_BOOLEAN, self::TYPE_LONG_TEXT]
DEFAULT_TYPE
public
mixed
DEFAULT_TYPE
= self::TYPE_STRING
TYPE_BOOLEAN
public
mixed
TYPE_BOOLEAN
= 'boolean'
TYPE_LONG_TEXT
public
mixed
TYPE_LONG_TEXT
= 'text'
TYPE_STRING
public
mixed
TYPE_STRING
= 'simple'
VERSION
public
mixed
VERSION
= '2'
Properties
$changed
protected
bool
$changed
= false
$data
protected
array<string|int, mixed>
$data
= []
$instance
protected
static static
$instance
$meta
protected
array<string|int, mixed>
$meta
= []
$path
protected
string|null
$path
Methods
__destruct()
Destructor auto save configuration
public
__destruct() : mixed
asArray()
Get it as array
public
asArray() : array<string|int, mixed>
Return values
array<string|int, mixed>get()
Get value by key
public
get(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
- $key : string
-
The key to look for
- $default : mixed|null = null
-
The default value if key is not set
Return values
mixed|nullgetData()
Get the data
public
getData() : array<string|int, mixed>
Return values
array<string|int, mixed>getInstance()
Get main instance
public
static getInstance() : AppConfig
Return values
AppConfiggetPath()
Get the path
public
getPath() : string|null
Return values
string|nullgetType()
Get the type of $key
public
getType(string $key) : string
Parameters
- $key : string
Return values
stringhas()
Test if config has $key
public
has(string $key) : bool
Parameters
- $key : string
Return values
boolinstance()
Alias for getInstance()
public
static instance() : AppConfig
Tags
Return values
AppConfigload()
Load config from filesystem
public
load() : void
Tags
loadSmartly()
Load config if it exists
public
loadSmartly() : void
Tags
preset()
Set $key if not yet set
public
preset(string $key, mixed $default[, string|null $type = null ]) : bool
Parameters
- $key : string
- $default : mixed
- $type : string|null = null
Return values
boolremove()
Test if config has $key
public
remove(string $key) : void
Parameters
- $key : string
save()
Save config into the filesystem
public
save() : int
Return values
intset()
Set the $value of $key
public
set(string $key, mixed $value) : bool
Parameters
- $key : string
- $value : mixed
Return values
boolsetData()
Set the data
public
setData(array<string|int, mixed> $data) : static
Parameters
- $data : array<string|int, mixed>
Return values
staticsetPath()
Set the path
public
setPath(string $path) : static
Parameters
- $path : string
Return values
static__construct()
AppConfig constructor
protected
__construct() : mixed