Fixing test bugs

This commit is contained in:
Dennis Eichhorn 2017-03-11 23:57:37 +01:00
parent fdd5d85a6a
commit aa483c2eb8
3 changed files with 18 additions and 28 deletions

View File

@ -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;
}
/**

View File

@ -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 <d.eichhorn@oms.com>
*/
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 <d.eichhorn@oms.com>
*/
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 <d.eichhorn@oms.com>
*/
public function getBrowser() : BrowserType
public function getBrowser() : string
{
if (!isset($this->browser)) {
$arr = BrowserType::getConstants();

View File

@ -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);