cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,23 +1,10 @@
<?php
/*
/**
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
@@ -27,41 +14,37 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
/**
* add twig function to render pagination
*
* @author Mathieu Jaumotte <mathieu.jaumotte@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
* add twig function to render pagination.
*/
class ChillItemsPerPageTwig extends AbstractExtension
{
public function getFunctions()
{
return [
new TwigFunction(
'chill_items_per_page',
[$this, 'paginationRender'],
[
'needs_environment' => true,
'is_safe' => ['html'],
]
),
];
}
public function getName()
{
return 'chill_items_per_page';
}
public function getFunctions()
{
return array(
new TwigFunction(
'chill_items_per_page',
array($this, 'paginationRender'),
array(
'needs_environment' => true,
'is_safe' => ['html']
)
)
);
}
public function paginationRender(
Environment $env,
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/items_per_page.html.twig'
Environment $env,
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/items_per_page.html.twig'
) {
return $env->render($template, array(
'paginator' => $paginator,
'current' => $paginator->getItemsPerPage()
));
return $env->render($template, [
'paginator' => $paginator,
'current' => $paginator->getItemsPerPage(),
]);
}
}

View File

@@ -1,23 +1,10 @@
<?php
/*
/**
* Chill is a software for social workers
*
* Copyright (C) 2016, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
@@ -27,54 +14,56 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
/**
* add twig function to render pagination
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
* add twig function to render pagination.
*/
class ChillPaginationTwig extends AbstractExtension
{
const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig';
const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig';
public const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig';
public const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig';
public function getFunctions()
{
return [
new TwigFunction(
'chill_pagination',
[$this, 'paginationRender'],
[
'needs_environment' => true,
'is_safe' => ['html'],
]
),
];
}
public function getName()
{
return 'chill_pagination';
}
public function getFunctions()
{
return array(
new TwigFunction(
'chill_pagination',
array($this, 'paginationRender'),
array(
'needs_environment' => true,
'is_safe' => ['html']
)
)
);
}
public function paginationRender(
Environment $env,
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/long.html.twig'
Environment $env,
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/long.html.twig'
) {
switch ($template) {
case 'long':
$t = self::LONG_TEMPLATE;
break;
case 'short':
$t = self::SHORT_TEMPLATE;
break;
default:
$t = $template;
}
return $env->render($t, array(
'paginator' => $paginator,
'current' => $paginator->getCurrentPage()->getNumber()
));
return $env->render($t, [
'paginator' => $paginator,
'current' => $paginator->getCurrentPage()->getNumber(),
]);
}
}

View File

@@ -1,21 +1,10 @@
<?php
/*
/**
* Chill is a software for social workers
* Copyright (C) 2016 Champs-Libres Coopérative <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
@@ -23,62 +12,57 @@ namespace Chill\MainBundle\Pagination;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* a page is an element of a pagination
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
* a page is an element of a pagination.
*/
class Page implements PageInterface
{
/**
*
* @var UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* the number of the current page
*
* @var int
*/
protected $number;
/**
* The route for the current page
*
* @var string
*/
protected $route;
/**
* Parameters for the route to the current page
*
* @var array
*/
protected $routeParameters;
/**
* the number of item per page
* the number of item per page.
*
* @var int
*/
protected $itemPerPage;
/**
* The number of items in the whole iteration
* the number of the current page.
*
* @var int
*/
protected $number;
/**
* The route for the current page.
*
* @var string
*/
protected $route;
/**
* Parameters for the route to the current page.
*
* @var array
*/
protected $routeParameters;
/**
* The number of items in the whole iteration.
*
* @var int
*/
protected $totalItems;
/**
* @var UrlGeneratorInterface
*/
protected $urlGenerator;
public function __construct(
$number,
$itemPerPage,
UrlGeneratorInterface $urlGenerator,
$route,
array $routeParameters,
$totalItems
$number,
$itemPerPage,
UrlGeneratorInterface $urlGenerator,
$route,
array $routeParameters,
$totalItems
) {
$this->urlGenerator = $urlGenerator;
$this->number = $number;
@@ -87,7 +71,7 @@ class Page implements PageInterface
$this->routeParameters = $routeParameters;
$this->totalItems = $totalItems;
}
public function generateUrl()
{
return $this->urlGenerator->generate($this->route, $this->routeParameters);
@@ -101,7 +85,7 @@ class Page implements PageInterface
public function getLastItemNumber()
{
$last = $this->number * $this->itemPerPage - 1;
return $last < $this->totalItems ? $last : $this->totalItems;
}
@@ -109,5 +93,4 @@ class Page implements PageInterface
{
return $this->number;
}
}

View File

@@ -1,21 +1,30 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
use Iterator;
/**
* PageGenerator associated with a Paginator.
*/
class PageGenerator implements \Iterator
class PageGenerator implements Iterator
{
protected Paginator $paginator;
protected int $current = 1;
protected Paginator $paginator;
public function __construct(Paginator $paginator)
{
$this->paginator = $paginator;;
$this->paginator = $paginator;
}
public function current()
@@ -30,7 +39,7 @@ class PageGenerator implements \Iterator
public function next()
{
$this->current++;
++$this->current;
}
public function rewind()
@@ -40,7 +49,7 @@ class PageGenerator implements \Iterator
public function valid()
{
return $this->current > 0
&& $this->current <= $this->paginator->countPages();
return 0 < $this->current
&& $this->paginator->countPages() >= $this->current;
}
}

View File

@@ -1,43 +1,29 @@
<?php
/*
/**
* Chill is a software for social workers
* Copyright (C) 2016 Champs-Libres Coopérative <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
/**
* Represents a page included in a pagination
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* Represents a page included in a pagination.
*/
interface PageInterface
{
public function generateUrl();
public function getFirstItemNumber();
public function getLastItemNumber();
/**
* get the page number.
*
* The first page number is 1.
*
* The first page number is 1.
*/
public function getNumber();
public function getFirstItemNumber();
public function getLastItemNumber();
}

View File

@@ -1,104 +1,90 @@
<?php
/*
/**
* Chill is a software for social workers
* Copyright (C) 2016 Champs-Libres Coopérative <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
use RuntimeException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Standard paginator class.
*
* Represent a set of paginated pages;
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
*/
class Paginator implements PaginatorInterface
{
/**
* The number of total items
*
* @var int
*/
protected $totalItems;
/**
* the number of items on a single page
*
* @var int
*/
protected $itemPerPage;
/**
* The number of the current page
* The number of the current page.
*
* @var int
*/
protected $currentPageNumber;
/**
* the route of the pages
* the number of items on a single page.
*
* @var string
* @var int
*/
protected $route;
protected $itemPerPage;
/**
* the parameters of the route
*
* @var string[]
*/
protected $routeParameters;
/**
* the generator for url
*
* @var UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* the key in the GET parameter to indicate the page number in
* generated routes
*
* @var string
*/
protected $pageKey;
/**
* the key in the GET parameter to indicate the number of item per page
* the key in the GET parameter to indicate the number of item per page.
*
* @var string
*/
protected $itemPerPageKey;
/**
* the key in the GET parameter to indicate the page number in
* generated routes.
*
* @var string
*/
protected $pageKey;
/**
* the route of the pages.
*
* @var string
*/
protected $route;
/**
* the parameters of the route.
*
* @var string[]
*/
protected $routeParameters;
/**
* The number of total items.
*
* @var int
*/
protected $totalItems;
/**
* the generator for url.
*
* @var UrlGeneratorInterface
*/
protected $urlGenerator;
public function __construct(
$totalItems,
$itemPerPage,
$currentPageNumber,
$route,
array $routeParameters,
UrlGeneratorInterface $urlGenerator,
$pageKey,
$itemPerPageKey
$totalItems,
$itemPerPage,
$currentPageNumber,
$route,
array $routeParameters,
UrlGeneratorInterface $urlGenerator,
$pageKey,
$itemPerPageKey
) {
$this->totalItems = $totalItems;
$this->itemPerPage = $itemPerPage;
@@ -115,8 +101,18 @@ class Paginator implements PaginatorInterface
return $this->countPages();
}
public function countPages()
{
$nb = floor($this->totalItems / $this->itemPerPage);
if ($this->totalItems % $this->itemPerPage > 0) {
++$nb;
}
return 0 == $nb ? 1 : (int) $nb;
}
/**
*
* @return \Chill\MainBundle\Pagination\Page
*/
public function getCurrentPage()
@@ -128,68 +124,78 @@ class Paginator implements PaginatorInterface
{
return $this->getCurrentPage()->getFirstItemNumber();
}
public function isCurrentPage(PageInterface $page)
{
return $page->getNumber() === $this->currentPageNumber;
}
public function getItemsPerPage()
public function getItemsPerPage()
{
return $this->itemPerPage;
}
public function setItemsPerPage($itemPerPage)
{
$this->itemPerPage = $itemPerPage;
}
public function getTotalItems()
{
return $this->totalItems;
}
public function countPages()
{
$nb = floor($this->totalItems / $this->itemPerPage);
if ($this->totalItems % $this->itemPerPage > 0) {
$nb++;
}
return $nb == 0 ? 1 : (int) $nb;
}
/**
* @throws RuntimeException if the next page does not exists
*
* @return \Chill\MainBundle\Pagination\Page
* @throws \RuntimeException if the next page does not exists
*/
public function getNextPage()
{
if (!$this->hasNextPage()) {
throw new \RuntimeException("this page has no next page");
throw new RuntimeException('this page has no next page');
}
return $this->getPage($this->currentPageNumber + 1);
}
/**
* @param type $number
*
* @return \Chill\MainBundle\Pagination\Page
*/
public function getPage($number)
{
if (!$this->hasPage($number)) {
throw new RuntimeException("The page with number {$number} does not "
. 'exists');
}
return new Page(
$number,
$this->itemPerPage,
$this->urlGenerator,
$this->route,
array_merge($this->routeParameters, [
$this->pageKey => $number,
$this->itemPerPageKey => $this->itemPerPage,
]),
$this->totalItems
);
}
public function getPagesGenerator()
{
for ($i = 1; $this->countPages() >= $i; ++$i) {
yield $this->getPage($i);
}
}
/**
* @throws RuntimeException if the next page does not exists
*
* @return \Chill\MainBundle\Pagination\Page
* @throws \RuntimeException if the next page does not exists
*/
public function getPreviousPage()
{
if (!$this->hasPreviousPage()) {
throw new \RuntimeException("this page has no previous page");
throw new RuntimeException('this page has no previous page');
}
return $this->getPage($this->currentPageNumber - 1);
}
public function getTotalItems()
{
return $this->totalItems;
}
/**
*
* @return bool
*/
public function hasNextPage()
@@ -197,51 +203,27 @@ class Paginator implements PaginatorInterface
return $this->hasPage($this->currentPageNumber + 1);
}
public function hasPage($number)
{
return 0 < $number
and $this->countPages() >= $number;
}
/**
*
* @return bool
*/
public function hasPreviousPage()
{
return $this->hasPage($this->currentPageNumber - 1);
}
public function hasPage($number)
public function isCurrentPage(PageInterface $page)
{
return $number > 0 and
$number <= $this->countPages();
return $page->getNumber() === $this->currentPageNumber;
}
/**
*
* @param type $number
* @return \Chill\MainBundle\Pagination\Page
*/
public function getPage($number) {
if (!$this->hasPage($number)) {
throw new \RuntimeException("The page with number $number does not "
. "exists");
}
return new Page(
$number,
$this->itemPerPage,
$this->urlGenerator,
$this->route,
array_merge($this->routeParameters, array(
$this->pageKey => $number,
$this->itemPerPageKey => $this->itemPerPage
)),
$this->totalItems
);
}
public function getPagesGenerator()
public function setItemsPerPage($itemPerPage)
{
for ($i = 1; $i <= $this->countPages(); $i++) {
yield $this->getPage($i);
}
$this->itemPerPage = $itemPerPage;
}
}

View File

@@ -1,36 +1,28 @@
<?php
/*
/**
* Chill is a software for social workers
* Copyright (C) 2016 Champs-Libres Coopérative <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface;
/**
* Create paginator instances
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
* Create paginator instances.
*/
class PaginatorFactory
{
public const DEFAULT_CURRENT_PAGE_KEY = 'page';
public const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page';
public const DEFAULT_PAGE_NUMBER = 1;
/**
* the default item per page. This may be overriden by
* the request or inside the paginator.
@@ -38,38 +30,33 @@ class PaginatorFactory
* @var int
*/
private $itemPerPage;
/**
* the router and generator for url
*
* @var RouterInterface
*/
private $router;
/**
* the request stack
* the request stack.
*
* @var RequestStack
*/
private $requestStack;
const DEFAULT_CURRENT_PAGE_KEY = 'page';
const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page';
const DEFAULT_PAGE_NUMBER = 1;
/**
* the router and generator for url.
*
* @var RouterInterface
*/
private $router;
public function __construct(
RequestStack $requestStack,
RouterInterface $router,
$itemPerPage = 20
RequestStack $requestStack,
RouterInterface $router,
$itemPerPage = 20
) {
$this->itemPerPage = $itemPerPage;
$this->requestStack = $requestStack;
$this->router = $router;
}
/**
* create a paginator instance
* create a paginator instance.
*
* The default route and route parameters are the current ones. If set,
* thos route are overriden.
@@ -77,70 +64,70 @@ class PaginatorFactory
* @param int $totalItems
* @param string|null $route the specific route to use in pages
* @param array|null $routeParameters the specific route parameters to use in pages
*
* @return PaginatorInterface
*/
public function create(
$totalItems,
$route = null,
array $routeParameters = null
$totalItems,
$route = null,
?array $routeParameters = null
) {
return new Paginator(
$totalItems,
$this->getCurrentItemsPerPage(),
$this->getCurrentPageNumber(),
$route === null ? $this->getCurrentRoute() : $route,
$routeParameters === null ? $this->getCurrentRouteParameters() :
$totalItems,
$this->getCurrentItemsPerPage(),
$this->getCurrentPageNumber(),
null === $route ? $this->getCurrentRoute() : $route,
null === $routeParameters ? $this->getCurrentRouteParameters() :
$routeParameters,
$this->router,
self::DEFAULT_CURRENT_PAGE_KEY,
self::DEFAULT_ITEM_PER_NUMBER_KEY);
$this->router,
self::DEFAULT_CURRENT_PAGE_KEY,
self::DEFAULT_ITEM_PER_NUMBER_KEY
);
}
/**
*
* @return int
*/
public function getCurrentPageNumber()
{
return $this->requestStack
->getCurrentRequest()
->query
->getInt(self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_PAGE_NUMBER);
}
public function getCurrentItemsPerPage()
{
return $this->requestStack
->getCurrentRequest()
->query
->getInt(self::DEFAULT_ITEM_PER_NUMBER_KEY, $this->itemPerPage);
->getCurrentRequest()
->query
->getInt(self::DEFAULT_ITEM_PER_NUMBER_KEY, $this->itemPerPage);
}
public function getCurrentPageFirstItemNumber()
{
return ($this->getCurrentPageNumber() - 1) *
$this->getCurrentItemsPerPage();
}
/**
* @return int
*/
public function getCurrentPageNumber()
{
return $this->requestStack
->getCurrentRequest()
->query
->getInt(self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_PAGE_NUMBER);
}
protected function getCurrentRoute()
{
$request = $this->requestStack->getCurrentRequest();
return $request->get('_route');
}
protected function getCurrentRouteParameters()
{
return array_merge(
$this->router->getContext()->getParameters(),
$this->router->getContext()->getParameters(),
// get the route parameters
$this->requestStack
->getCurrentRequest()
->attributes->get('_route_params'),
->getCurrentRequest()
->attributes->get('_route_params'),
// get the query parameters
$this->requestStack
->getCurrentRequest()->query->all()
);
->getCurrentRequest()->query->all()
);
}
}

View File

@@ -1,27 +1,20 @@
<?php
/*
/**
* Chill is a software for social workers
* Copyright (C) 2016 Champs-Libres Coopérative <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Pagination;
use Countable;
use Generator;
use RuntimeException;
/**
* Represent a set of numbered pages
* Represent a set of numbered pages.
*
* Allow to calculate and render pagination for a set of pages.
*
@@ -29,108 +22,108 @@ namespace Chill\MainBundle\Pagination;
* into pages. Each page is numbered and count a given number of item per page.
*
* The first page number is 1, although the first result number is 0.
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
interface PaginatorInterface extends \Countable
interface PaginatorInterface extends Countable
{
/**
* get the number of results for this paginator
*
* @return int
*/
public function getTotalItems();
/**
* get the first result for the current page
*
* @return int
*/
public function getCurrentPageFirstItemNumber();
/*
* get the number of items per page
*/
public function getItemsPerPage();
/*
* set the number of items per page
*/
public function setItemsPerPage($itemsPerPage);
/**
* get the number of pages for this pagination.
*
* @return int
*/
public function countPages();
/**
* get the current page
* get the current page.
*
* @return PageInterface
*/
public function getCurrentPage();
/**
* check if the given page is the current page
* get the first result for the current page.
*
* @param \Chill\MainBundle\Pagination\PageInterface $page
* @return bool
* @return int
*/
public function isCurrentPage(PageInterface $page);
public function getCurrentPageFirstItemNumber();
/*
* get the number of items per page
*/
public function getItemsPerPage();
/**
* check if the page with the given number exists
* get the next page.
*
* @param int $number
*/
public function hasPage($number);
/**
* get page by his number
*
* @param int $number
* @throws \RuntimeException if the pagination has no page with specified number
*/
public function getPage($number);
/**
* get the next page
* @throws RuntimeException if the pagination has not next page
*
* @return PageInterface
* @throws \RuntimeException if the pagination has not next page
*/
public function getNextPage();
/**
* get the previous page
* get page by his number.
*
* @param int $number
*
* @throws RuntimeException if the pagination has no page with specified number
*/
public function getPage($number);
/**
* get a generator to generate pages.
*
* @return Generator which return PageInterface elements
*/
public function getPagesGenerator();
/**
* get the previous page.
*
* @throws RuntimeException if the pagination has not previous page
*
* @return PageInterface
* @throws \RuntimeException if the pagination has not previous page
*/
public function getPreviousPage();
/**
* check if the current page has a next page
* get the number of results for this paginator.
*
* @return int
*/
public function getTotalItems();
/**
* check if the current page has a next page.
*
* @return bool
*/
public function hasNextPage();
/**
* check if the current page has a page before
* check if the page with the given number exists.
*
* @param int $number
*/
public function hasPage($number);
/**
* check if the current page has a page before.
*
* @return bool
*/
public function hasPreviousPage();
/**
* get a generator to generate pages
* check if the given page is the current page.
*
* @return \Generator which return PageInterface elements
* @param \Chill\MainBundle\Pagination\PageInterface $page
*
* @return bool
*/
public function getPagesGenerator();
public function isCurrentPage(PageInterface $page);
/*
* set the number of items per page
*/
public function setItemsPerPage($itemsPerPage);
}