From e550bd51289174a7973d3f666d2970ceeccd6a73 Mon Sep 17 00:00:00 2001 From: Sergio Salvatore Date: Tue, 23 Jan 2024 12:06:42 -0500 Subject: [PATCH] Convenience Method for Instantiating the Right FakePDO Given that there are different versions for php7 vs. php8, provide a convenience method for getting the right one rather than having to have switching logic in the calling code... --- src/FakePdo.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/FakePdo.php diff --git a/src/FakePdo.php b/src/FakePdo.php new file mode 100644 index 00000000..6774a1a3 --- /dev/null +++ b/src/FakePdo.php @@ -0,0 +1,27 @@ + $options any options + * @return PDO + */ + public static function getFakePdo( + string $connection_string, + string $username, + string $password, + array $options + ): PDO { + if (\PHP_MAJOR_VERSION === 8) { + return new Php8\FakePdo($connection_string, $username, $password, $options); + } + + return new Php7\FakePdo($connection_string, $username, $password, $options); + } +}