class Collection extends SimpleCollection

Class DataCollector - 数据收集器 (数据存储器 - DataStorage) complex deep

Constants

FORMAT_JSON

FORMAT_PHP

FORMAT_INI

FORMAT_YML

Properties

protected array $data The source data from SimpleCollection
protected string $separator Property separator.
protected string $name name
static protected array $formats formats

Methods

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

No description

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

__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

Details

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 78
__construct(mixed $data = null, string $format = 'php', string $name = 'box1')

__construct

Parameters

mixed $data
string $format
string $name

Exceptions

RangeException

in SimpleCollection at line 40
__destruct()

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

set config value by path

Parameters

string $path
$value

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

Parameters

$name
$value

Return Value

$this

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

get value by path

Parameters

string $path
$default

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

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

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

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

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

at line 123
exists($path)

Parameters

$path

at line 137
reset()

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

Parameters

$class

Return Value

mixed

at line 165
string getSeparator()

Return Value

string

at line 173
setSeparator(string $separator)

Parameters

string $separator

at line 181
static array getFormats()

Return Value

array

at line 191
$this setName(string $value)

setName

Parameters

string $value

Return Value

$this

at line 202
string getName()

getName

Return Value

string

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

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

Parameters

$file
string $format

Return Value

array|mixed

at line 264
Collection loadYaml($data)

load data form yml file

Parameters

$data

Return Value

Collection

Exceptions

RuntimeException

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

load data form php file or array

Parameters

array|string $data

Return Value

Collection

Exceptions

InvalidArgumentException

at line 294
Collection loadObject(mixed $data)

load data form php file or array

Parameters

mixed $data

Return Value

Collection

Exceptions

InvalidArgumentException

at line 308
Collection loadIni(string $string)

load data form ini file

Parameters

string $string

Return Value

Collection

at line 319
Collection loadJson($data)

load data form json file

Parameters

$data

Return Value

Collection

Exceptions

RuntimeException

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

Parameters

$parent
$data
bool|false $raw

Return Value

$this

at line 359
array getKeys()

Return Value

array

at line 382
__clone()

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

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

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