Skip to content

Commit

Permalink
Merge pull request #356 from perftools/default-direction
Browse files Browse the repository at this point in the history
Use same default direction for pdo/mongodb
  • Loading branch information
glensc authored Oct 23, 2020
2 parents 3aff293 + 8a26df1 commit 667e205
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Xhgui/Db/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateInterval;
use DateTime;
use MongoDate;
use XHGui\Searcher\SearcherInterface;

class Mapper
{
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Xhgui/Searcher/PdoSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Xhgui/Searcher/SearcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
interface SearcherInterface
{
const DEFAULT_DIRECTION = 'desc';

/**
* Get the latest profile data.
*
Expand Down

0 comments on commit 667e205

Please sign in to comment.