diff --git a/Autoloader.php b/Autoloader.php index 54703cb81..06112f46d 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -52,8 +52,12 @@ class Autoloader $class = ltrim($class, '\\'); $class = str_replace(['_', '\\'], '/', $class); + if(!file_exists($path = __DIR__ . '/../' . $class . '.php')) { + return; + } + /** @noinspection PhpIncludeInspection */ - include_once __DIR__ . '/../' . $class . '.php'; + include_once $path; } /** diff --git a/Message/Http/Request.php b/Message/Http/Request.php index d275da3e6..a8d6f27ee 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -83,6 +83,8 @@ class Request extends RequestAbstract $this->uri = $uri; $this->source = RequestSource::WEB; $this->header = new Header(); + + $this->init(); } /** @@ -97,12 +99,10 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function init($uri = null) /* : void */ + private function init() /* : void */ { - if (!isset($uri) && !isset($this->uri)) { + if (!isset($this->uri)) { $this->initCurrentRequest(); - } else { - $this->initPseudoRequest($uri ?? $this->uri->__toString()); } $this->data = array_change_key_case($this->data, CASE_LOWER); @@ -159,30 +159,16 @@ class Request extends RequestAbstract */ private function loadRequestLanguage() : string { - $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; - $lang = explode(';', $lang); + if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + return 'EN'; + } + + $lang = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $lang = explode('-', $lang[0]); return $lang[0]; } - /** - * Init pseudo request - * - * @param mixed $uri Uri to handle as request - * - * @return void - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - private function initPseudoRequest($uri) /* : void */ - { - // todo: $uri can be string and this will fail!!! - $this->setMethod($uri['type']); - $this->uri->set($uri['uri']); - } - /** * Clean up globals that musn't be used any longer * @@ -297,12 +283,12 @@ class Request extends RequestAbstract /** * Determine request browser. * - * @return BrowserType + * @return string * * @since 1.0.0 * @author Dennis Eichhorn */ - public function getBrowser() : BrowserType + public function getBrowser() : string { if (!isset($this->browser)) { $arr = BrowserType::getConstants(); diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index 3e8f46fa0..39571ef75 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -363,9 +363,9 @@ class StringUtils return $count; } - public static function getEntropy(string $value) : int + public static function getEntropy(string $value) : float { - $entroy = 0; + $entroy = 0.0; $size = mb_strlen($value); $countChars = self::mb_count_chars($value, 1);