diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-01-22 18:16:30 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-01-22 18:16:30 +0100 |
commit | bcf13551bee63417cce1cf030c016eeb8855b751 (patch) | |
tree | b9b2c4b11d66c812638a9c4b2d928f2badaea088 /phpBB/phpbb/db | |
parent | f9f43141a91ce07916cc327b7fd94afba7bfb7bf (diff) | |
parent | 11b6bc5722a6a4aed1cd45ce65f2d9cf16ae7dd5 (diff) | |
download | forums-bcf13551bee63417cce1cf030c016eeb8855b751.tar forums-bcf13551bee63417cce1cf030c016eeb8855b751.tar.gz forums-bcf13551bee63417cce1cf030c016eeb8855b751.tar.bz2 forums-bcf13551bee63417cce1cf030c016eeb8855b751.tar.xz forums-bcf13551bee63417cce1cf030c016eeb8855b751.zip |
Merge pull request #3275 from nickvergessen/ticket/13487
[ticket/13487] Add factory for db tool class
Diffstat (limited to 'phpBB/phpbb/db')
-rw-r--r-- | phpBB/phpbb/db/tools/factory.php | 35 |
1 files changed, 35 insertions, 0 deletions
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 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @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'); + } +} |