Config
class Config extends Collection
Config file loader and writer
Traits
Properties
protected array | $data | Collection items data | from Collection |
protected array | $comments | Config array comments | from PhpConfigFile |
Methods
Constructor
Create colection form json file
Merge collection items
Push value to collection
Add value to begining of collection array
Return true if key exists and value not empty in collection
Export array as text
Get cache
Set read protecetd vars keys
Set write protecetd vars keys
Return true if var is not read protected
Return true if var is not write protected
Get config file name
Reload config file
Set config dir
Read config file
Load config file
Save config file
Load json config file
Check if file exist
Details
at line 67
__construct(string|null $fileName = 'config.php', CacheInterface|null $cache = null, string $dir)
Constructor
in Collection at line 45
static Collection
create(array $data)
Create colleciton
in Collection at line 58
static Collection
createFromFile(string $fileName, string|null $root = null, array|null $vars = null)
Create colection form json file
in Collection at line 73
ArrayIterator
getIterator()
Return iterator
in Collection at line 84
bool
has(string $key)
Return true if key exists in collection
in Collection at line 95
bool
offsetExists(string $key)
Return true if key exists in collection
in Collection at line 106
Collection
union(array $data)
Union arrays
in Collection at line 119
Collection
replace(array $replacement)
Replace array
in Collection at line 132
mixed
offsetGet(string $key)
Get item
in Collection at line 144
void
offsetSet(string $key, mixed $value)
Set item
in Collection at line 155
void
offsetUnset(string $key)
Remove item
in Collection at line 166
Collection
remove(string $key)
Remove item
in Collection at line 178
void
removeEmptyItems()
Remove empy items
in Collection at line 190
integer
count()
Return collection items count.
in Collection at line 202
void
setBooleanValue(string $path, integer|string $value)
Set bool value
in Collection at line 221
void
setValue(string $path, mixed $value)
Set item value by path
in Collection at line 234
void
merge(string $key, array $data, bool $recursive = false)
Merge collection items
in Collection at line 249
void
mergeItems(array $data, bool $recursive = false)
Merge all collection items
in Collection at line 261
Collection
set(string $key, mixed $value)
Set item value in collection
in Collection at line 275
void
add(string $key, mixed $value)
Add item to collection
in Collection at line 292
bool
push(string $key, mixed $value, string|null $subKey = null)
Push value to collection
in Collection at line 319
bool
prepend(string $key, mixed $value, string|null $subKey = null)
Add value to begining of collection array
in Collection at line 343
Collection
withData(array $data)
Set collection data
in Collection at line 356
array
slice(array|string $keys)
Slice collecion by keys
in Collection at line 366
array
toArray()
Return collection array
in Collection at line 377
bool
isEmpty(string $key)
Return true if key exists and value not empty in collection
in Collection at line 388
Collection
getCollection(string $key)
Get collection item
in Collection at line 400
mixed
get(string $key, mixed $default = null)
Get value from collection
in Collection at line 412
bool
getBool(string $key, bool|null $default = null)
Get boolean value
in Collection at line 424
string|null
getString(string $key, string|null $default = null)
Get text value
in Collection at line 438
int|null
getInt(string $key, int|null $default = null)
Get int value
in Collection at line 452
float|null
getFloat(string $key, float|null $default = null)
Get float value
in Collection at line 466
array
getArray(string $key, mixed $default = null)
Return array values
in Collection at line 478
void
clear()
Clear collection data
in Collection at line 488
Collection
copy()
Clone object
in Collection at line 499
mixed
__get(string $key)
Get value
in Collection at line 510
__set(string $key, mixed $value)
Set value
in Collection at line 522
mixed
getByPath(string $path, mixed $default = null)
Get value by path
in Collection at line 536
bool
addField(string $path, mixed $value)
Add value
in Collection at line 555
array
getItems()
Get collection items
in PhpConfigFile at line 33
array|null
include(string $fileName)
Include config file
in PhpConfigFile at line 44
array|null
includePhpArray(string $fileName)
Include php array
in PhpConfigFile at line 62
protected void
setComment(string $comment, string $key)
Set array key comment
in PhpConfigFile at line 73
protected string
getCommentsText(string $key)
Get array imtem comment as text
in PhpConfigFile at line 100
protected string
exportArray(array $data, string $arrayKey, int $currentTab = 1, int $endTab = 1)
Export array as text
in PhpConfigFile at line 144
protected string
exportItem(string $key, mixed $value, int $maxTabs)
Export item as text
in PhpConfigFile at line 158
protected string
exportConfig(array $data)
Export config as text
in PhpConfigFile at line 245
bool
saveConfigFile(string $fileName, array $data)
Save config file
at line 85
CacheInterface|null
getCache()
Get cache
at line 96
void
setReadProtectedVars(array $keys)
Set read protecetd vars keys
at line 107
void
setWriteProtectedVars(array $keys)
Set write protecetd vars keys
at line 118
bool
hasReadAccess(string $key)
Return true if var is not read protected
at line 129
bool
hasWriteAccess(string $key)
Return true if var is not write protected
at line 139
string
getConfigFile()
Get config file name
at line 150
void
reloadConfig(bool $useCache = false)
Reload config file
at line 166
void
setConfigDir(string $dir)
Set config dir
at line 178
static Collection
read(string $fileName, string $configDir)
Read config file
at line 190
array
load(string $fileName, bool $useCache = true)
Load config file
at line 216
bool
save(string|null $fileName = null, array|null $data = null)
Save config file
at line 234
array
loadJsonConfigFile(string $fileName)
Load json config file
at line 247
bool
hasConfigFile(string $fileName)
Check if file exist