Skip to content

Commit

Permalink
improving countable
Browse files Browse the repository at this point in the history
  • Loading branch information
jturbide committed Feb 29, 2024
1 parent 2c58c8d commit 7531f51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Mvc/Controller/Rest/Actions/CountAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function countAction(): ResponseInterface
$model = $this->getModelClassName();

$countResult = $model::count($this->getFindCount($this->getFind()));
$count = is_array($countResult) ? count($countResult) : $countResult;
$count = is_countable($countResult) ? count($countResult) : (int)$countResult;

$this->view->setVar('count', $count);
return $this->setRestResponse(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Controller/Rest/Actions/GetListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getListAction(): ResponseInterface
$find = $this->getFind() ?: [];

$totalCount = $model::count($this->getFindCount($find));
$totalCount = is_int($totalCount) ? $totalCount : count($totalCount);
$totalCount = is_countable($totalCount)? count($totalCount) : (int)$totalCount;
$this->view->setVars([
'list' => $this->listExpose($model::findWith($with, $find)),
'totalCount' => $totalCount,
Expand Down

0 comments on commit 7531f51

Please sign in to comment.