Другая интерпретация реестра

This commit is contained in:
CORP\phedor 2018-04-20 18:03:39 +03:00
parent 40fad0e75b
commit aaa9c2e1bf
21 changed files with 156 additions and 92 deletions

40
src/Registry.php Normal file
View file

@ -0,0 +1,40 @@
<?php
namespace ctiso;
use ctiso\File,
Exception;
class Registry {
public $namespace = [];
function importFile($namespace, $filePath = null) {
$data = json_decode(File::getContents($filePath), true);
$data['_file'] = $filePath;
$this->namespace[$namespace] = [
'path' => $filePath,
'data' => $data
];
}
function importArray($namespace, $data = []) {
if (isset($this->namespace[$namespace])) {
$data = array_merge($this->namespace[$namespace]['data'], $data);
}
$this->namespace[$namespace] = [
'path' => null,
'data' => $data
];
}
public function get($ns, $key) {
return $this->namespace[$ns]['data'][$key];
}
public function has($ns, $key) {
return isset($this->namespace[$ns]['data'][$key]);
}
function set($ns, $key, $value) {
$this->namespace[$ns]['data'][$key] = $value;
}
}