class Configuration extends Collection

Class Configuration - 配置数据管理

Constants

FORMAT_JSON

FORMAT_PHP

FORMAT_INI

FORMAT_YML

MODE_DATA

MODE_FOLDER

Properties

protected array $data The source data from SimpleCollection
protected string $separator Property separator. from Collection
protected string $name name from Collection
static protected array $formats formats from Collection
protected string $mode config mode Allow: folder 文件夹模式,传入一个配置文件夹路径,根据文件夹中的配置名称读取配置数据 data 数据模式,可以一个配置文件的路径,将会自动读取载入;或直接传入数组数据
protected string $format

Methods

make(mixed $data = null, string $format = 'php', string $name = 'box1')

No description

__construct(mixed $data = null, string $format = self::FORMAT_PHP, string $name = 'config')

__construct

__destruct()

No description

set(string $path, $value)

set config value by path

$this
add($name, $value)

No description

get(string $path, $default = null)

get value by path

replace(array $items)

Add item to collection

array
gets(array $names)

No description

sets(array $data)

No description

reject(callable $filter)

No description

map(callable $callback)

No description

string
implode(string $char = ',')

No description

array
all()

Get all items in collection

array
toArray()

No description

array
keys()

Get collection keys

bool
has(string $path)

No description

mixed
remove($key)

Remove item from collection

clear()

Clear all data.

bool
offsetExists(string $key)

Does this collection have a given key?

mixed
offsetGet(string $key)

Get collection item for key

offsetSet(string $key, mixed $value)

Set collection item

mixed|null
offsetUnset(mixed $offset)

Unset an offset in the iterator.

int
count()

Get number of items in collection

array
jsonSerialize()

No description

string
serialize()

No description

unserialize(string $serialized, bool|array $allowedClasses = false)

No description

getIterator()

No description

mixed
__get($name)

No description

__set($name, $value)

No description

__isset($name)

No description

exists($path)

No description

reset()

No description

mixed
toObject($class = \stdClass::class)

No description

string
getSeparator()

No description

setSeparator(string $separator)

No description

static array
getFormats()

No description

$this
setName(string $value)

setName

string
getName()

getName

load(string|array $data, string $format = 'php')

load

static array|mixed
read($file, string $format = self::FORMAT_PHP)

No description

loadYaml($data)

load data form yml file

loadArray(array|string $data)

load data form php file or array

loadObject(mixed $data)

load data form php file or array

loadIni(string $string)

load data form ini file

loadJson($data)

load data form json file

$this
bindData($parent, $data, bool|false $raw = false)

No description

array
getKeys()

No description

__clone()

No description

static array
parseIni($string, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

No description

static array
parseJson($data, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

No description

static array
parseYaml(string|bool $data, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

parse YAML

string
getMode()

get Mode

setMode(string $mode)

No description

setReadonly(bool $readonly)

No description

boolean
isReadonly()

data is Readonly

string
getFormat()

No description

setFormat(string $format)

No description

string
getFolderPath()

No description

setFolderPath(string $folderPath)

No description

Details

in Collection at line 94
static SimpleCollection make(mixed $data = null, string $format = 'php', string $name = 'box1')

Parameters

mixed $data
string $format
string $name

Return Value

SimpleCollection

at line 61
__construct(mixed $data = null, string $format = self::FORMAT_PHP, string $name = 'config')

__construct

Parameters

mixed $data
string $format
string $name

Exceptions

RuntimeException

in SimpleCollection at line 40
__destruct()

at line 85
set(string $path, $value)

set config value by path

Parameters

string $path
$value

Exceptions

RuntimeException

in SimpleCollection at line 67
$this add($name, $value)

Parameters

$name
$value

Return Value

$this

at line 102
get(string $path, $default = null)

get value by path

Parameters

string $path
$default

Exceptions

RuntimeException

in SimpleCollection at line 91
replace(array $items)

Add item to collection

Parameters

array $items

in SimpleCollection at line 102
array gets(array $names)

Parameters

array $names

Return Value

array

in SimpleCollection at line 117
SimpleCollection sets(array $data)

Parameters

array $data

Return Value

SimpleCollection

in SimpleCollection at line 130
SimpleCollection reject(callable $filter)

Parameters

callable $filter

Return Value

SimpleCollection

in SimpleCollection at line 149
SimpleCollection map(callable $callback)

Parameters

callable $callback

Return Value

SimpleCollection

in SimpleCollection at line 165
string implode(string $char = ',')

Parameters

string $char

Return Value

string

in SimpleCollection at line 174
array all()

Get all items in collection

Return Value

array

in SimpleCollection at line 182
array toArray()

Return Value

array

in SimpleCollection at line 191
array keys()

Get collection keys

Return Value

array The collection's source data keys

in Collection at line 132
bool has(string $path)

Parameters

string $path

Return Value

bool

in SimpleCollection at line 211
mixed remove($key)

Remove item from collection

Parameters

$key

Return Value

mixed

in Collection at line 148
clear()

Clear all data.

in SimpleCollection at line 240
bool offsetExists(string $key)

Does this collection have a given key?

Parameters

string $key The data key

Return Value

bool

in SimpleCollection at line 250
mixed offsetGet(string $key)

Get collection item for key

Parameters

string $key The data key

Return Value

mixed The key's value, or the default value

in SimpleCollection at line 260
offsetSet(string $key, mixed $value)

Set collection item

Parameters

string $key The data key
mixed $value The data value

in Collection at line 377
mixed|null offsetUnset(mixed $offset)

Unset an offset in the iterator.

Parameters

mixed $offset The array offset.

Return Value

mixed|null

in SimpleCollection at line 283
int count()

Get number of items in collection

Return Value

int

in SimpleCollection at line 295
array jsonSerialize()

Return Value

array

in SimpleCollection at line 307
string serialize()

Return Value

string

in SimpleCollection at line 316
unserialize(string $serialized, bool|array $allowedClasses = false)

Parameters

string $serialized
bool|array $allowedClasses

in Collection at line 367
ArrayIterator getIterator()

Return Value

ArrayIterator

in SimpleCollection at line 342
mixed __get($name)

Parameters

$name

Return Value

mixed

in SimpleCollection at line 347
__set($name, $value)

Parameters

$name
$value

in SimpleCollection at line 352
__isset($name)

Parameters

$name

in Collection at line 123
exists($path)

Parameters

$path

in Collection at line 137
reset()

in Collection at line 157
mixed toObject($class = \stdClass::class)

Parameters

$class

Return Value

mixed

in Collection at line 165
string getSeparator()

Return Value

string

in Collection at line 173
setSeparator(string $separator)

Parameters

string $separator

in Collection at line 181
static array getFormats()

Return Value

array

in Collection at line 191
$this setName(string $value)

setName

Parameters

string $value

Return Value

$this

in Collection at line 202
string getName()

getName

Return Value

string

in Collection at line 215
Collection load(string|array $data, string $format = 'php')

load

Parameters

string|array $data
string $format = 'php'

Return Value

Collection

Exceptions

RuntimeException
RangeException

in Collection at line 253
static array|mixed read($file, string $format = self::FORMAT_PHP)

Parameters

$file
string $format

Return Value

array|mixed

in Collection at line 264
Collection loadYaml($data)

load data form yml file

Parameters

$data

Return Value

Collection

Exceptions

RuntimeException

in Collection at line 275
Collection loadArray(array|string $data)

load data form php file or array

Parameters

array|string $data

Return Value

Collection

Exceptions

InvalidArgumentException

in Collection at line 294
Collection loadObject(mixed $data)

load data form php file or array

Parameters

mixed $data

Return Value

Collection

Exceptions

InvalidArgumentException

in Collection at line 308
Collection loadIni(string $string)

load data form ini file

Parameters

string $string

Return Value

Collection

in Collection at line 319
Collection loadJson($data)

load data form json file

Parameters

$data

Return Value

Collection

Exceptions

RuntimeException

in Collection at line 330
protected $this bindData($parent, $data, bool|false $raw = false)

Parameters

$parent
$data
bool|false $raw

Return Value

$this

in Collection at line 359
array getKeys()

Return Value

array

in Collection at line 382
__clone()

in Collection at line 398
static array parseIni($string, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

Parameters

$string
bool $enhancement
callable $pathHandler
string $fileDir

Return Value

array

in Collection at line 410
static array parseJson($data, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

Parameters

$data
bool $enhancement
callable $pathHandler
string $fileDir

Return Value

array

in Collection at line 423
static array parseYaml(string|bool $data, bool $enhancement = false, callable $pathHandler = null, string $fileDir = '')

parse YAML

Parameters

string|bool $data Waiting for the parse data
bool $enhancement Simple support import other config by tag 'import'. must is bool.
callable $pathHandler When the second param is true, this param is valid.
string $fileDir When the second param is true, this param is valid.

Return Value

array

at line 127
string getMode()

get Mode

Return Value

string

at line 135
setMode(string $mode)

Parameters

string $mode

at line 143
setReadonly(bool $readonly)

Parameters

bool $readonly

at line 152
boolean isReadonly()

data is Readonly

Return Value

boolean

at line 160
string getFormat()

Return Value

string

at line 168
setFormat(string $format)

Parameters

string $format

at line 176
string getFolderPath()

Return Value

string

at line 185
setFolderPath(string $folderPath)

Parameters

string $folderPath

Exceptions

InvalidArgumentException