Add default case/exception for database type

This commit is contained in:
Dennis Eichhorn 2018-01-16 19:04:12 +01:00
parent 24c6194f5c
commit 029fdb4600
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Exception;
/**
* Permission exception class.
*
* @package Framework
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class InvalidDatabaseTypeException extends \InvalidArgumentException
{
/**
* Constructor.
*
* @param string $message Exception message
* @param int $code Exception code
* @param \Exception $previous Previous exception
*
* @since 1.0.0
*/
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
{
parent::__construct('Invalid database type "' . $message . '".', $code, $previous);
}
}

View File

@ -17,6 +17,7 @@ namespace phpOMS\Module;
use phpOMS\ApplicationAbstract;
use phpOMS\Autoloader;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\DataStorage\Database\Exception\InvalidDatabaseTypeException;
use phpOMS\Message\Http\Request;
use phpOMS\Message\RequestAbstract;
use phpOMS\System\File\PathException;
@ -174,6 +175,9 @@ class ModuleManager
$sth->execute();
$this->uriLoad = $sth->fetchAll(\PDO::FETCH_GROUP);
break;
default:
throw new InvalidDatabaseTypeException($this->app->dbPool->get('select')->getType());
}
}
@ -198,6 +202,8 @@ class ModuleManager
$sth->execute();
$this->active = $sth->fetchAll(\PDO::FETCH_COLUMN);
break;
default:
throw new InvalidDatabaseTypeException($this->app->dbPool->get('select')->getType());
}
}
@ -269,6 +275,8 @@ class ModuleManager
$sth->execute();
$this->installed = $sth->fetchAll(\PDO::FETCH_GROUP);
break;
default:
throw new InvalidDatabaseTypeException($this->app->dbPool->get('select')->getType());
}
}