adding readDir to Config
This commit is contained in:
parent
1af7fe0b37
commit
1f1980ba23
1 changed files with 17 additions and 0 deletions
|
@ -8,6 +8,23 @@ use Flatrr\FlatArray;
|
||||||
|
|
||||||
class Config extends SelfReferencingFlatArray implements ConfigInterface
|
class Config extends SelfReferencingFlatArray implements ConfigInterface
|
||||||
{
|
{
|
||||||
|
public function readDir($dir, string $name = null, bool $overwrite = null)
|
||||||
|
{
|
||||||
|
$dir = realpath($dir);
|
||||||
|
if (!$dir || !is_dir($dir)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (glob("$dir/*") as $f) {
|
||||||
|
if (is_file($f)) {
|
||||||
|
try {
|
||||||
|
$this->readFile($f, $name, $overwrite);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
//ignore exceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function parse(string $input, string $format) : array
|
protected function parse(string $input, string $format) : array
|
||||||
{
|
{
|
||||||
$fn = 'parse_'.$format;
|
$fn = 'parse_'.$format;
|
||||||
|
|
Loading…
Reference in a new issue