Config
in package
Config Class for simple config manipulation of multiple formats.
Table of Contents
- CNF = \pocketmine\utils\Config::PROPERTIES
- DETECT = -1
- ENUM = 5
- ENUMERATION = \pocketmine\utils\Config::ENUM
- JSON = 1
- PROPERTIES = 0
- SERIALIZED = 4
- YAML = 2
- $formats : array<string|int, int>
- $changed : bool
- $config : array<string|int, mixed>
- $file : string
- $jsonOptions : int
- $nestedCache : array<string|int, mixed>
- $type : int
- __construct() : mixed
- __get() : bool|mixed
- __isset() : bool
- __set() : void
- __unset() : mixed
- disableJsonOption() : $this
- Disables the given option for the JSON encoding when saving
- enableJsonOption() : $this
- Enables the given option in addition to the currently set JSON options
- exists() : bool
- fixYAMLIndexes() : string
- get() : bool|mixed
- getAll() : array<string|int, mixed>
- getJsonOptions() : int
- Returns the options for the JSON encoding when saving
- getNested() : mixed
- getPath() : string
- Returns the path of the config.
- hasChanged() : bool
- parseList() : array<string|int, string>
- parseProperties() : array<string|int, string>|array<string|int, int>|array<string|int, float>|array<string|int, bool>
- reload() : void
- Removes all the changes in memory and loads the file again
- remove() : void
- removeNested() : void
- save() : void
- Flushes the config to disk in the appropriate format.
- set() : void
- setAll() : void
- setChanged() : void
- setDefaults() : void
- setJsonOptions() : $this
- Sets the options for the JSON encoding when saving
- setNested() : void
- writeList() : string
- writeProperties() : string
- fillDefaults() : int
- load() : void
Constants
CNF
public
mixed
CNF
= \pocketmine\utils\Config::PROPERTIES
DETECT
public
mixed
DETECT
= -1
ENUM
public
mixed
ENUM
= 5
ENUMERATION
public
mixed
ENUMERATION
= \pocketmine\utils\Config::ENUM
JSON
public
mixed
JSON
= 1
PROPERTIES
public
mixed
PROPERTIES
= 0
SERIALIZED
public
mixed
SERIALIZED
= 4
YAML
public
mixed
YAML
= 2
Properties
$formats
public
static array<string|int, int>
$formats
= [
"properties" => \pocketmine\utils\Config::PROPERTIES,
"cnf" => \pocketmine\utils\Config::CNF,
"conf" => \pocketmine\utils\Config::CNF,
"config" => \pocketmine\utils\Config::CNF,
"json" => \pocketmine\utils\Config::JSON,
"js" => \pocketmine\utils\Config::JSON,
"yml" => \pocketmine\utils\Config::YAML,
"yaml" => \pocketmine\utils\Config::YAML,
//"export" => Config::EXPORT,
//"xport" => Config::EXPORT,
"sl" => \pocketmine\utils\Config::SERIALIZED,
"serialize" => \pocketmine\utils\Config::SERIALIZED,
"txt" => \pocketmine\utils\Config::ENUM,
"list" => \pocketmine\utils\Config::ENUM,
"enum" => \pocketmine\utils\Config::ENUM,
]
$changed
private
bool
$changed
= false
$config
private
array<string|int, mixed>
$config
= []
Tags
$file
private
string
$file
$jsonOptions
private
int
$jsonOptions
= \JSON_PRETTY_PRINT | \JSON_BIGINT_AS_STRING
$nestedCache
private
array<string|int, mixed>
$nestedCache
= []
Tags
$type
private
int
$type
= \pocketmine\utils\Config::DETECT
Methods
__construct()
public
__construct(string $file[, int $type = Config::DETECT ][, array<string|int, mixed> $default = [] ]) : mixed
Parameters
- $file : string
-
Path of the file to be loaded
- $type : int = Config::DETECT
-
Config type to load, -1 by default (detect)
- $default : array<string|int, mixed> = []
-
Array with the default values that will be written to the file if it did not exist
Tags
Return values
mixed —__get()
public
__get(string $k) : bool|mixed
Parameters
- $k : string
Return values
bool|mixed —__isset()
public
__isset(string $k) : bool
Parameters
- $k : string
Return values
bool —__set()
public
__set(string $k, mixed $v) : void
Parameters
- $k : string
- $v : mixed
Return values
void —__unset()
public
__unset(string $k) : mixed
Parameters
- $k : string
Return values
mixed —disableJsonOption()
Disables the given option for the JSON encoding when saving
public
disableJsonOption(int $option) : $this
Parameters
- $option : int
Tags
Return values
$this —enableJsonOption()
Enables the given option in addition to the currently set JSON options
public
enableJsonOption(int $option) : $this
Parameters
- $option : int
Tags
Return values
$this —exists()
public
exists(string $k[, bool $lowercase = false ]) : bool
Parameters
- $k : string
- $lowercase : bool = false
-
If set, searches Config in single-case / lowercase.
Return values
bool —fixYAMLIndexes()
public
static fixYAMLIndexes(string $str) : string
Parameters
- $str : string
Return values
string —get()
public
get(string $k[, mixed $default = false ]) : bool|mixed
Parameters
- $k : string
- $default : mixed = false
Return values
bool|mixed —getAll()
public
getAll([bool $keys = false ]) : array<string|int, mixed>
Parameters
- $keys : bool = false
Tags
Return values
array<string|int, mixed> —getJsonOptions()
Returns the options for the JSON encoding when saving
public
getJsonOptions() : int
Tags
Return values
int —getNested()
public
getNested(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
Return values
mixed —getPath()
Returns the path of the config.
public
getPath() : string
Return values
string —hasChanged()
public
hasChanged() : bool
Return values
bool —parseList()
public
static parseList(string $content) : array<string|int, string>
Parameters
- $content : string
Tags
Return values
array<string|int, string> —parseProperties()
public
static parseProperties(string $content) : array<string|int, string>|array<string|int, int>|array<string|int, float>|array<string|int, bool>
Parameters
- $content : string
Tags
Return values
array<string|int, string>|array<string|int, int>|array<string|int, float>|array<string|int, bool> —reload()
Removes all the changes in memory and loads the file again
public
reload() : void
Return values
void —remove()
public
remove(string $k) : void
Parameters
- $k : string
Return values
void —removeNested()
public
removeNested(string $key) : void
Parameters
- $key : string
Return values
void —save()
Flushes the config to disk in the appropriate format.
public
save() : void
Return values
void —set()
public
set(string $k[, mixed $v = true ]) : void
Parameters
- $k : string
-
key to be set
- $v : mixed = true
-
value to set key
Return values
void —setAll()
public
setAll(array<string|int, mixed> $v) : void
Parameters
- $v : array<string|int, mixed>
Tags
Return values
void —setChanged()
public
setChanged([bool $changed = true ]) : void
Parameters
- $changed : bool = true
Return values
void —setDefaults()
public
setDefaults(array<string|int, mixed> $defaults) : void
Parameters
- $defaults : array<string|int, mixed>
Tags
Return values
void —setJsonOptions()
Sets the options for the JSON encoding when saving
public
setJsonOptions(int $options) : $this
Parameters
- $options : int
Tags
Return values
$this —setNested()
public
setNested(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
Return values
void —writeList()
public
static writeList(array<string|int, string> $entries) : string
Parameters
- $entries : array<string|int, string>
Tags
Return values
string —writeProperties()
public
static writeProperties(array<string|int, string>|array<string|int, int>|array<string|int, float>|array<string|int, bool> $config) : string
Parameters
- $config : array<string|int, string>|array<string|int, int>|array<string|int, float>|array<string|int, bool>
Tags
Return values
string —fillDefaults()
private
fillDefaults(array<string|int, mixed> $default, array<string|int, mixed> &$data) : int
Parameters
- $default : array<string|int, mixed>
- $data : array<string|int, mixed>
-
reference parameter
Tags
Return values
int —load()
private
load(string $file[, int $type = Config::DETECT ][, array<string|int, mixed> $default = [] ]) : void
Parameters
- $file : string
- $type : int = Config::DETECT
- $default : array<string|int, mixed> = []