apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -30,7 +30,6 @@ class Page implements PageInterface
protected int $number,
/**
* the number of item per page.
*
*/
protected int $itemPerPage,
UrlGeneratorInterface $urlGenerator,

View File

@@ -11,12 +11,10 @@ declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
use Iterator;
/**
* PageGenerator associated with a Paginator.
*/
class PageGenerator implements Iterator
class PageGenerator implements \Iterator
{
protected int $current = 1;

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
use RuntimeException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
@@ -100,28 +99,21 @@ class Paginator implements PaginatorInterface
}
/**
* @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(): Page
{
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);
}
/**
*
* @return \Chill\MainBundle\Pagination\Page
*/
public function getPage(int $number): Page
{
if (!$this->hasPage($number)) {
throw new RuntimeException("The page with number {$number} does not "
. 'exists');
throw new \RuntimeException("The page with number {$number} does not ".'exists');
}
return new Page(
@@ -145,14 +137,14 @@ class Paginator implements PaginatorInterface
}
/**
* @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(): PageInterface
{
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);
@@ -163,9 +155,6 @@ class Paginator implements PaginatorInterface
return $this->totalItems;
}
/**
* @return bool
*/
public function hasNextPage(): bool
{
return $this->hasPage($this->currentPageNumber + 1);
@@ -181,9 +170,6 @@ class Paginator implements PaginatorInterface
&& $this->countPages() >= $number;
}
/**
* @return bool
*/
public function hasPreviousPage(): bool
{
return $this->hasPage($this->currentPageNumber - 1);

View File

@@ -50,16 +50,16 @@ class PaginatorFactory
* The default route and route parameters are the current ones. If set,
* thos route are overriden.
*
* @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
* @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,
?string $route = null,
?array $routeParameters = null
string $route = null,
array $routeParameters = null
) {
return new Paginator(
$totalItems,

View File

@@ -11,9 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
use Countable;
use Generator;
use RuntimeException;
/**
* Represent a set of numbered pages.
@@ -25,26 +23,20 @@ use RuntimeException;
*
* The first page number is 1, although the first result number is 0.
*/
interface PaginatorInterface extends Countable
interface PaginatorInterface extends \Countable
{
/**
* get the number of pages for this pagination.
*
* @return int
*/
public function countPages(): int;
/**
* get the current page.
*
* @return PageInterface
*/
public function getCurrentPage(): PageInterface;
/**
* get the first result for the current page.
*
* @return int
*/
public function getCurrentPageFirstItemNumber(): int;
@@ -56,71 +48,53 @@ interface PaginatorInterface extends Countable
/**
* 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(): PageInterface;
/**
* get page by his number.
*
* @param int $number
*
* @throws RuntimeException if the pagination has no page with specified number
* @throws \RuntimeException if the pagination has no page with specified number
*/
public function getPage(int $number): PageInterface;
/**
* get a generator to generate pages.
*
* @return Generator which return PageInterface elements
* @return \Generator which return PageInterface elements
*/
public function getPagesGenerator(): iterable;
/**
* 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(): PageInterface;
/**
* get the number of results for this paginator.
*
* @return int
*/
public function getTotalItems(): int;
/**
* check if the current page has a next page.
*
* @return bool
*/
public function hasNextPage(): bool;
/**
* check if the page with the given number exists.
*
* @param mixed $number
*/
public function hasPage($number): bool;
/**
* check if the current page has a page before.
*
* @return bool
*/
public function hasPreviousPage(): bool;
/**
* check if the given page is the current page.
*
* @param \Chill\MainBundle\Pagination\PageInterface $page
*
* @return bool
*/
public function isCurrentPage(PageInterface $page): bool;