Skip to content

Commit

Permalink
fix(question): Use "single scalar result"
Browse files Browse the repository at this point in the history
  • Loading branch information
pan93412 committed Dec 30, 2024
1 parent fcbdece commit e55b467
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Repository/QuestionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public function getNextPage(int $page): ?int
{
try {
$result = $this->createQueryBuilder('q')
->select('q')
->select('q.id')
->where('q.id > :page')
->orderBy('q.id', 'ASC')
->setParameter('page', $page)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
->getSingleScalarResult()
;

\assert(\is_int($result) || null === $result, 'result should be an integer or null');
\assert(\is_int($result), 'result should be an integer');

return $result;
} catch (NoResultException) {
Expand All @@ -55,10 +55,10 @@ public function getPreviousPage(int $page): ?int
->setParameter('page', $page)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
->getSingleScalarResult()
;

\assert(\is_int($result) || null === $result, 'result should be an integer or null');
\assert(\is_int($result), 'result should be an integer');

return $result;
} catch (NoResultException) {
Expand Down

0 comments on commit e55b467

Please sign in to comment.