for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Cqrs package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Cqrs\ReadModel\Storage\Finder;
/**
* @author Iqbal Maulana <[email protected]>
* @created 3/25/16
class Pagination
{
* @var int
public $limit;
public $current;
public $prev = null;
public $next = null;
public $pages = 0;
public $total;
* Constructor.
* @param int $limit
* @param int $current
public function __construct($limit, $current)
$this->limit = $limit;
$this->current = $current;
if (1 !== $current) {
$this->prev = $current - 1;
}
* @param int $total
public function calc($total)
$this->pages = ceil($total / $this->limit);
$pages
integer
ceil($total / $this->limit)
double
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
if ($this->current < $this->pages) {
$this->next = $this->current + 1;
* @return array
public function serialize()
return array(
'prev' => $this->prev,
'current' => $this->current,
'next' => $this->next,
'pages' => $this->pages,
);
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.