Orpheus

AppConfig
in package

The AppConfig class

Store application configuration in a file

Tags
author

Florent Hazard contact@sowapps.com

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'

Properties

$data

protected array<string|int, mixed> $data = []

$meta

protected array<string|int, mixed> $meta = []

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

getData()

Get the data

public getData() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPath()

Get the path

public getPath() : string|null
Return values
string|null

getType()

Get the type of $key

public getType(string $key) : string
Parameters
$key : string
Return values
string

has()

Test if config has $key

public has(string $key) : bool
Parameters
$key : string
Return values
bool

load()

Load config from filesystem

public load() : void
Tags
throws
Exception

loadSmartly()

Load config if it exists

public loadSmartly() : void
Tags
throws
Exception

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
bool

remove()

Test if config has $key

public remove(string $key) : void
Parameters
$key : string

save()

Save config into the filesystem

public save() : int
Return values
int

set()

Set the $value of $key

public set(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Return values
bool

setData()

Set the data

public setData(array<string|int, mixed> $data) : static
Parameters
$data : array<string|int, mixed>
Return values
static

setPath()

Set the path

public setPath(string $path) : static
Parameters
$path : string
Return values
static

__construct()

AppConfig constructor

protected __construct() : mixed
Tags
throws
Exception

							
On this page

Search results