adding readDir to Config

This commit is contained in:
Joby 2020-06-18 10:28:25 -06:00
parent 1af7fe0b37
commit 1f1980ba23

View file

@ -8,6 +8,23 @@ use Flatrr\FlatArray;
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
{
$fn = 'parse_'.$format;