From 11b6bc5722a6a4aed1cd45ce65f2d9cf16ae7dd5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Jan 2015 15:43:18 +0100 Subject: [ticket/13487] Add factory for db tool class This allows us to split up the large file one by one easily. PHPBB3-13487 --- phpBB/phpbb/db/tools/factory.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 phpBB/phpbb/db/tools/factory.php (limited to 'phpBB/phpbb/db/tools') diff --git a/phpBB/phpbb/db/tools/factory.php b/phpBB/phpbb/db/tools/factory.php new file mode 100644 index 0000000000..60db2ade03 --- /dev/null +++ b/phpBB/phpbb/db/tools/factory.php @@ -0,0 +1,35 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\tools; + +/** + * A factory which serves the suitable tools instance for the given dbal + */ +class factory +{ + /** + * @param mixed $db_driver + * @param bool $return_statements + * @return \phpbb\db\tools\tools_interface + */ + public function get($db_driver, $return_statements = false) + { + if ($db_driver instanceof \phpbb\db\driver\driver_interface) + { + return new \phpbb\db\tools\tools($db_driver, $return_statements); + } + + throw new \InvalidArgumentException('Invalid database driver given'); + } +} -- cgit v1.2.1