Ip\Config::__construct PHP Method

__construct() public method

public __construct ( $config, array | null $server = null )
$config
$server array | null $_SERVER
    public function __construct($config, $server = null)
    {
        $this->config = $config;
        if (!isset($this->config['tablePrefix'])) {
            $this->config['tablePrefix'] = $this->config['db']['tablePrefix'];
        }
        if (!isset($this->config['database'])) {
            $this->config['database'] = $this->config['db']['database'];
        }
        if (!$server) {
            $server = $_SERVER;
        }
        if (empty($this->config['baseUrl'])) {
            $this->config['baseUrl'] = $server["HTTP_HOST"];
            $baseUrl = substr($server['SCRIPT_NAME'], 0, strrpos($server['SCRIPT_NAME'], '/') + 1);
            if (DIRECTORY_SEPARATOR == '/') {
                // unix system
                if (strpos($server['REQUEST_URI'], $baseUrl) !== 0) {
                    // show instructions how to set baseUrl manually
                    include __DIR__ . '/Internal/Config/view/couldNotDetectBaseUrl.php';
                    exit;
                }
            } else {
                // windows system
                if (strpos(strtolower($server['REQUEST_URI']), strtolower($baseUrl)) !== 0) {
                    // show instructions how to set baseUrl manually
                    include __DIR__ . '/Internal/Config/view/couldNotDetectBaseUrl.php';
                    exit;
                }
            }
            $this->config['baseUrl'] .= rtrim($baseUrl, '/') . '/';
        }
        if (empty($this->config['baseDir'])) {
            $this->config['baseDir'] = realpath(dirname($server['SCRIPT_FILENAME']));
        }
        if (empty($this->config['charset'])) {
            $this->config['charset'] = 'UTF-8';
        }
        if (empty($this->config['defaultDoctype'])) {
            $this->config['defaultDoctype'] = 'DOCTYPE_HTML5';
        }
        if (isset($server['HTTPS']) && strtolower($server['HTTPS']) == "on" || strtolower(getenv('HTTP_X_FORWARDED_PROTO')) === 'https') {
            $this->protocol = 'https';
        } else {
            $this->protocol = 'http';
        }
        $this->protocolUrl = $this->protocol . '://';
    }