diff --git a/Contract/Object.php b/Contract/Object.php deleted file mode 100644 index 11b8c1ebf..000000000 --- a/Contract/Object.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Dennis Eichhorn - * @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 - * @author Dennis Eichhorn - * @license OMS License 1.0 - * @link http://orange-management.com - * @since 1.0.0 - */ -interface Object -{ -} diff --git a/DataStorage/Cache/CacheFactory.php b/DataStorage/Cache/CacheFactory.php index 2f59baf78..79b8370ef 100644 --- a/DataStorage/Cache/CacheFactory.php +++ b/DataStorage/Cache/CacheFactory.php @@ -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.'); } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index 5ee4e61b7..ca2b170f9 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -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 */ - 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; } /** diff --git a/DataStorage/Database/Connection/ConnectionFactory.php b/DataStorage/Database/Connection/ConnectionFactory.php index c2226aa65..acdea26ce 100644 --- a/DataStorage/Database/Connection/ConnectionFactory.php +++ b/DataStorage/Database/Connection/ConnectionFactory.php @@ -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); diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index cd8453ee2..8cdb173c1 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -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']); diff --git a/Utils/Converter/Ip.php b/Utils/Converter/Ip.php index a6d959c96..a6c09c53c 100644 --- a/Utils/Converter/Ip.php +++ b/Utils/Converter/Ip.php @@ -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++; diff --git a/Validation/Base/IP.php b/Validation/Base/IP.php index d7c561f73..fdc00dfc3 100644 --- a/Validation/Base/IP.php +++ b/Validation/Base/IP.php @@ -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; } }