From ad3f91bf24967d51ab6d65a33dadb9d1bdb961c8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 8 Sep 2017 19:34:33 +0200 Subject: [PATCH] fix return types --- .../Database/DatabaseExceptionFactory.php | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/DataStorage/Database/DatabaseExceptionFactory.php b/DataStorage/Database/DatabaseExceptionFactory.php index 3348b22c6..7a88508d4 100644 --- a/DataStorage/Database/DatabaseExceptionFactory.php +++ b/DataStorage/Database/DatabaseExceptionFactory.php @@ -15,8 +15,6 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database; -use phpOMS\DataStorage\Database\Schema\Exception\TableException; - /** * Database exception factory. * @@ -33,17 +31,17 @@ class DatabaseExceptionFactory * * @param \PDOException $e Exception * - * @return \PDOException + * @return string * * @since 1.0.0 */ - public static function createException(\PDOException $e) : \PDOException + public static function createException(\PDOException $e) : string { switch ($e->getCode()) { case '42S02': - return self::createTableViewException($e); + return '\phpOMS\DataStorage\Database\Schema\Exception\TableException'; default: - return $e; + return '\PDOException'; } } @@ -52,31 +50,17 @@ class DatabaseExceptionFactory * * @param \PDOException $e Exception * - * @return \PDOException + * @return string * * @since 1.0.0 */ - public static function createExceptionMessage(\PDOException $e) : \PDOException + public static function createExceptionMessage(\PDOException $e) : string { switch ($e->getCode()) { case '42S02': - return self::createTableViewExceptionMessage($e); + return TableException::findTable($e->getMessage()); default: - return $e; + return $e->getMessage(); } } - - /** - * Create table exception. - * - * @param \PDOException $e Exception - * - * @return \PDOException - * - * @since 1.0.0 - */ - private static function createTableViewException(\PDOException $e) : string - { - return TableException::findTable($e->getMessage()); - } }