PocketMine-MP 5.21.3 git-fcef015f32c0b0709cfd4d6f1b3c32f484b25bde
Loading...
Searching...
No Matches
pocketmine\utils\Config Class Reference
+ Collaboration diagram for pocketmine\utils\Config:

Public Member Functions

 __construct (string $file, int $type=Config::DETECT, array $default=[])
 
 __get ($k)
 
 __isset ($k)
 
 __set ($k, $v)
 
 __unset ($k)
 
 disableJsonOption (int $option)
 
 enableJsonOption (int $option)
 
 exists (string $k, bool $lowercase=false)
 
 get (string $k, mixed $default=false)
 
 getAll (bool $keys=false)
 
 getJsonOptions ()
 
 getNested (string $key, mixed $default=null)
 
 getPath ()
 
 hasChanged ()
 
 reload ()
 
 remove (string $k)
 
 removeNested (string $key)
 
 save ()
 
 set (string $k, mixed $v=true)
 
 setAll (array $v)
 
 setChanged (bool $changed=true)
 
 setDefaults (array $defaults)
 
 setJsonOptions (int $options)
 
 setNested (string $key, mixed $value)
 

Static Public Member Functions

static fixYAMLIndexes (string $str)
 
static parseList (string $content)
 
static parseProperties (string $content)
 
static writeList (array $entries)
 
static writeProperties (array $config)
 

Public Attributes

const CNF = Config::PROPERTIES
 
const DETECT = -1
 
const ENUM = 5
 
const ENUMERATION = Config::ENUM
 
const JSON = 1
 
const PROPERTIES = 0
 
const SERIALIZED = 4
 
const YAML = 2
 

Static Public Attributes

static array $formats
 

Detailed Description

Config Class for simple config manipulation of multiple formats.

Definition at line 62 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\utils\Config::__construct ( string $file,
int $type = Config::DETECT,
array $default = [] )
Parameters
string$filePath of the file to be loaded
int$typeConfig type to load, -1 by default (detect)
mixed[]$defaultArray with the default values that will be written to the file if it did not exist @phpstan-param array<string, mixed> $default

Definition at line 116 of file Config.php.

Member Function Documentation

◆ __get()

pocketmine\utils\Config::__get ( $k)
Parameters
string$k
Returns
bool|mixed

Definition at line 313 of file Config.php.

◆ __isset()

pocketmine\utils\Config::__isset ( $k)
Parameters
string$k
Returns
bool

Definition at line 330 of file Config.php.

◆ __set()

pocketmine\utils\Config::__set ( $k,
$v )
Parameters
string$k
mixed$v

Definition at line 321 of file Config.php.

◆ __unset()

pocketmine\utils\Config::__unset ( $k)
Parameters
string$k

Definition at line 337 of file Config.php.

◆ disableJsonOption()

pocketmine\utils\Config::disableJsonOption ( int $option)

Disables the given option for the JSON encoding when saving

Returns
$this
Exceptions

RuntimeException if the Config is not in JSON

See also
json_encode

Definition at line 285 of file Config.php.

◆ enableJsonOption()

pocketmine\utils\Config::enableJsonOption ( int $option)

Enables the given option in addition to the currently set JSON options

Returns
$this
Exceptions

RuntimeException if the Config is not in JSON

See also
json_encode

Definition at line 268 of file Config.php.

◆ exists()

pocketmine\utils\Config::exists ( string $k,
bool $lowercase = false )
Parameters
bool$lowercaseIf set, searches Config in single-case / lowercase.

Definition at line 436 of file Config.php.

◆ fixYAMLIndexes()

static pocketmine\utils\Config::fixYAMLIndexes ( string $str)
static

Definition at line 137 of file Config.php.

◆ get()

pocketmine\utils\Config::get ( string $k,
mixed $default = false )

Definition at line 410 of file Config.php.

◆ getAll()

pocketmine\utils\Config::getAll ( bool $keys = false)
Returns
mixed[] @phpstan-return list<string>|array<string, mixed>

Definition at line 455 of file Config.php.

◆ getJsonOptions()

pocketmine\utils\Config::getJsonOptions ( )

Returns the options for the JSON encoding when saving

Exceptions

RuntimeException if the Config is not in JSON

See also
json_encode

Definition at line 301 of file Config.php.

◆ getNested()

pocketmine\utils\Config::getNested ( string $key,
mixed $default = null )

Definition at line 364 of file Config.php.

◆ getPath()

pocketmine\utils\Config::getPath ( )

Returns the path of the config.

Definition at line 210 of file Config.php.

◆ hasChanged()

pocketmine\utils\Config::hasChanged ( )

Definition at line 129 of file Config.php.

◆ parseList()

static pocketmine\utils\Config::parseList ( string $content)
static
Returns
string[] @phpstan-return list<string>

Definition at line 499 of file Config.php.

◆ parseProperties()

static pocketmine\utils\Config::parseProperties ( string $content)
static
Returns
string[]|int[]|float[]|bool[] @phpstan-return array<string, string|int|float|bool>

Definition at line 539 of file Config.php.

◆ reload()

pocketmine\utils\Config::reload ( )

Removes all the changes in memory and loads the file again

Definition at line 123 of file Config.php.

◆ remove()

pocketmine\utils\Config::remove ( string $k)

Definition at line 446 of file Config.php.

◆ removeNested()

pocketmine\utils\Config::removeNested ( string $key)

Definition at line 389 of file Config.php.

◆ save()

pocketmine\utils\Config::save ( )

Flushes the config to disk in the appropriate format.

Definition at line 217 of file Config.php.

◆ set()

pocketmine\utils\Config::set ( string $k,
mixed $v = true )

Definition at line 414 of file Config.php.

◆ setAll()

pocketmine\utils\Config::setAll ( array $v)
Parameters
mixed[]$v@phpstan-param array<string, mixed> $v

Definition at line 428 of file Config.php.

◆ setChanged()

pocketmine\utils\Config::setChanged ( bool $changed = true)

Definition at line 133 of file Config.php.

◆ setDefaults()

pocketmine\utils\Config::setDefaults ( array $defaults)
Parameters
mixed[]$defaults@phpstan-param array<string, mixed> $defaults

Definition at line 463 of file Config.php.

◆ setJsonOptions()

pocketmine\utils\Config::setJsonOptions ( int $options)

Sets the options for the JSON encoding when saving

Returns
$this
Exceptions

RuntimeException if the Config is not in JSON

See also
json_encode

Definition at line 251 of file Config.php.

◆ setNested()

pocketmine\utils\Config::setNested ( string $key,
mixed $value )

Definition at line 341 of file Config.php.

◆ writeList()

static pocketmine\utils\Config::writeList ( array $entries)
static
Parameters
string[]$entries@phpstan-param list<string> $entries

Definition at line 515 of file Config.php.

◆ writeProperties()

static pocketmine\utils\Config::writeProperties ( array $config)
static
Parameters
string[] | int[] | float[] | bool[]$config@phpstan-param array<string, string|int|float|bool> $config

Definition at line 523 of file Config.php.

Member Data Documentation

◆ $formats

array pocketmine\utils\Config::$formats
static
Initial value:
= [
"properties" => Config::PROPERTIES,
"cnf" => Config::CNF,
"conf" => Config::CNF,
"config" => Config::CNF,
"json" => Config::JSON,
"js" => Config::JSON,
"yml" => Config::YAML,
"yaml" => Config::YAML,
"sl" => Config::SERIALIZED,
"serialize" => Config::SERIALIZED,
"txt" => Config::ENUM,
"list" => Config::ENUM,
"enum" => Config::ENUM
]

Definition at line 92 of file Config.php.

◆ CNF

const pocketmine\utils\Config::CNF = Config::PROPERTIES

Definition at line 65 of file Config.php.

◆ DETECT

const pocketmine\utils\Config::DETECT = -1

Definition at line 63 of file Config.php.

◆ ENUM

const pocketmine\utils\Config::ENUM = 5

Definition at line 70 of file Config.php.

◆ ENUMERATION

const pocketmine\utils\Config::ENUMERATION = Config::ENUM

Definition at line 71 of file Config.php.

◆ JSON

const pocketmine\utils\Config::JSON = 1

Definition at line 66 of file Config.php.

◆ PROPERTIES

const pocketmine\utils\Config::PROPERTIES = 0

Definition at line 64 of file Config.php.

◆ SERIALIZED

const pocketmine\utils\Config::SERIALIZED = 4

Definition at line 69 of file Config.php.

◆ YAML

const pocketmine\utils\Config::YAML = 2

Definition at line 67 of file Config.php.


The documentation for this class was generated from the following file: