first code

This commit is contained in:
Bryan Joshua Pedini 2020-12-27 15:32:59 +01:00
parent 3eeaf7f652
commit 86dcbe8a13
1 changed files with 32 additions and 0 deletions

32
Object.php Normal file
View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
class config {
private array $config;
public function __construct(string $config_path = "/config.php") {
require_once(__DIR__."/../..".$config_path);
$this->config = $global_config;
unset($global_config);
}
public function get(string $key):array|string {
if(strpos($key, ".") !== FALSE) {
$keys = explode(".", $key);
$arr = $this->config;
$ret = "";
foreach($keys as $keyn) {
if(gettype($arr[$keyn]) === "array") {
$arr = $this->config[$keyn];
} else {
$ret = $arr[$keyn];
}
}
return $ret;
}
return $this->config[$key];
}
public function get_all():array {
return $this->config;
}
}