From 1b629632bbb67a3229aa503dbed3dc311871cf36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 20 Dec 2020 08:16:34 +0200 Subject: [PATCH 1/3] Add NotImplementedException class --- src/Xhgui/Exception/NotImplementedException.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/Xhgui/Exception/NotImplementedException.php diff --git a/src/Xhgui/Exception/NotImplementedException.php b/src/Xhgui/Exception/NotImplementedException.php new file mode 100644 index 000000000..638c482b8 --- /dev/null +++ b/src/Xhgui/Exception/NotImplementedException.php @@ -0,0 +1,9 @@ + Date: Sun, 20 Dec 2020 08:18:54 +0200 Subject: [PATCH 2/3] Add notImplementedPdo method to NotImplementedException --- src/Xhgui/Exception/NotImplementedException.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Xhgui/Exception/NotImplementedException.php b/src/Xhgui/Exception/NotImplementedException.php index 638c482b8..b0104621f 100644 --- a/src/Xhgui/Exception/NotImplementedException.php +++ b/src/Xhgui/Exception/NotImplementedException.php @@ -6,4 +6,8 @@ class NotImplementedException extends RuntimeException { + public static function notImplementedPdo(string $method): self + { + throw new self(sprintf('%s not implemented for PDO', $method)); + } } From 9b449b5fb6f93ed404ca627ad008b8930c5c2605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 20 Dec 2020 08:20:06 +0200 Subject: [PATCH 3/3] Throw exception instead if silently failing This is call developers: implement (even partial) support rather returning wrong types (null) --- src/Xhgui/Searcher/PdoSearcher.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Xhgui/Searcher/PdoSearcher.php b/src/Xhgui/Searcher/PdoSearcher.php index acbbcdf72..74a5809c9 100644 --- a/src/Xhgui/Searcher/PdoSearcher.php +++ b/src/Xhgui/Searcher/PdoSearcher.php @@ -3,6 +3,7 @@ namespace XHGui\Searcher; use XHGui\Db\PdoRepository; +use XHGui\Exception\NotImplementedException; use XHGui\Options\SearchOptions; use XHGui\Profile; @@ -39,12 +40,9 @@ public function latest(): Profile ]); } - /** - * {@inheritdoc} - */ public function query($conditions, $limit, $fields = []) { - // TODO: Implement query() method. + throw NotImplementedException::notImplementedPdo(__METHOD__); } /** @@ -70,20 +68,14 @@ public function get($id): Profile ]); } - /** - * {@inheritdoc} - */ public function getForUrl($url, $options, $conditions = []) { - // TODO: Implement getForUrl() method. + throw NotImplementedException::notImplementedPdo(__METHOD__); } - /** - * {@inheritdoc} - */ public function getPercentileForUrl($percentile, $url, $search = []) { - // TODO: Implement getPercentileForUrl() method. + throw NotImplementedException::notImplementedPdo(__METHOD__); } /** @@ -91,7 +83,7 @@ public function getPercentileForUrl($percentile, $url, $search = []) */ public function getAvgsForUrl($url, $search = []) { - // TODO: Implement getAvgsForUrl() method. + throw NotImplementedException::notImplementedPdo(__METHOD__); } /**