Test adjustments

This commit is contained in:
Dennis Eichhorn 2017-02-13 21:28:58 +01:00
parent a88514ef7c
commit a49fd7f9ad
7 changed files with 31 additions and 44 deletions

View File

@ -1,33 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace phpOMS\Contract;
/**
* Degenerate interface for type hinting object.
*
* @category Framework
* @package phpOMS\Contract
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
interface Object
{
}

View File

@ -64,7 +64,6 @@ class CacheFactory
switch ($cacheData['type']) {
case 'file':
return new FileCache($cacheData['path']);
break;
default:
throw new \InvalidArgumentException('Cache "' . $cacheData['type'] . '" is not supported.');
}

View File

@ -122,15 +122,26 @@ class CookieJar
*
* @param string $id Cookie id to remove
*
* @return void
* @return bool
*
* @throws LockException
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function delete(string $id) /* : void */
public function delete(string $id) : bool
{
$this->remove($id);
setcookie($id, '', time() - 3600);
if($this->remove($id)) {
if (self::$isLocked) {
throw new LockException('CookieJar');
}
setcookie($id, '', time() - 3600);
return true;
}
return false;
}
/**

View File

@ -17,7 +17,6 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Database\Connection;
/**
* Database connection factory.
*
@ -58,6 +57,7 @@ class ConnectionFactory
*/
public static function create(array $dbdata) : ConnectionInterface
{
// todo: replace string with enum
switch ($dbdata['db']) {
case 'mysql':
return new MysqlConnection($dbdata);

View File

@ -65,7 +65,7 @@ class MysqlConnection extends ConnectionAbstract
$this->close();
$this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata;
$this->prefix = $dbdata['prefix'];
$this->prefix = $dbdata['prefix'] ?? '';
try {
$this->con = new \PDO($this->dbdata['db'] . ':host=' . $this->dbdata['host'] . ':' . $this->dbdata['port'] . ';dbname=' . $this->dbdata['database'] . ';charset=utf8', $this->dbdata['login'], $this->dbdata['password']);

View File

@ -67,11 +67,11 @@ class Ip
if ($ip > $split[1]) {
$larger = true;
$start = $current;
fseek($fh, ($end - $current) / 2, SEEK_CUR);
fseek($fh, (int) (($end - $current) / 2), SEEK_CUR);
} else {
$larger = false;
$end = $current;
fseek($fh, ($start - $current) / 2, SEEK_CUR);
fseek($fh, (int) (($start - $current) / 2), SEEK_CUR);
}
$counter++;

View File

@ -30,7 +30,7 @@ use phpOMS\Validation\ValidatorAbstract;
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class IP extends ValidatorAbstract
abstract class Ip extends ValidatorAbstract
{
/**
@ -48,6 +48,16 @@ abstract class IP extends ValidatorAbstract
*/
public static function isValid($value) : bool
{
return filter_var($value, FILTER_VALIDATE_IP);
return filter_var($value, FILTER_VALIDATE_IP) !== false;
}
public static function isValidIpv6($value) : bool
{
return filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
}
public static function isValidIpv4($value) : bool
{
return filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
}
}