From 8a26df1db81d8e65e5a01d16717023d18f6df58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 23 Oct 2020 06:17:23 +0300 Subject: [PATCH] Use same default direction for pdo/mongodb --- src/Xhgui/Db/Mapper.php | 3 ++- src/Xhgui/Searcher/PdoSearcher.php | 2 +- src/Xhgui/Searcher/SearcherInterface.php | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Xhgui/Db/Mapper.php b/src/Xhgui/Db/Mapper.php index 40f62808d..fbdb518a3 100644 --- a/src/Xhgui/Db/Mapper.php +++ b/src/Xhgui/Db/Mapper.php @@ -5,6 +5,7 @@ use DateInterval; use DateTime; use MongoDate; +use XHGui\Searcher\SearcherInterface; class Mapper { @@ -114,7 +115,7 @@ protected function _convertDate($dateString) protected function _direction($options) { if (empty($options['direction'])) { - return 'desc'; + return SearcherInterface::DEFAULT_DIRECTION; } $valid = ['desc', 'asc']; if (in_array($options['direction'], $valid, true)) { diff --git a/src/Xhgui/Searcher/PdoSearcher.php b/src/Xhgui/Searcher/PdoSearcher.php index 683ca3e90..43a70ec77 100644 --- a/src/Xhgui/Searcher/PdoSearcher.php +++ b/src/Xhgui/Searcher/PdoSearcher.php @@ -99,7 +99,7 @@ public function getAvgsForUrl($url, $search = []) public function getAll($options = []) { $page = (int)$options['page']; - $direction = $options['direction'] ?? 'asc'; + $direction = $options['direction'] ?? SearcherInterface::DEFAULT_DIRECTION; if ($page < 1) { $page = 1; } diff --git a/src/Xhgui/Searcher/SearcherInterface.php b/src/Xhgui/Searcher/SearcherInterface.php index f8880e0f5..fa4a6182e 100644 --- a/src/Xhgui/Searcher/SearcherInterface.php +++ b/src/Xhgui/Searcher/SearcherInterface.php @@ -11,6 +11,8 @@ */ interface SearcherInterface { + const DEFAULT_DIRECTION = 'desc'; + /** * Get the latest profile data. *