vendor/knplabs/knp-components/src/Knp/Component/Pager/Pagination/AbstractPagination.php line 7

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Pagination;
  3. use Iterator;
  4. abstract class AbstractPagination implements IteratorPaginationInterface
  5. {
  6.     protected $currentPageNumber;
  7.     protected $numItemsPerPage;
  8.     protected $items = [];
  9.     protected $totalCount;
  10.     protected $paginatorOptions;
  11.     protected $customParameters;
  12.     public function rewind(): void
  13.     {
  14.         reset($this->items);
  15.     }
  16.     /**
  17.      * @return mixed
  18.      */
  19.     public function current()
  20.     {
  21.         return current($this->items);
  22.     }
  23.     /**
  24.      * @return bool|float|int|string|null
  25.      */
  26.     public function key()
  27.     {
  28.         return key($this->items);
  29.     }
  30.     public function next(): void
  31.     {
  32.         next($this->items);
  33.     }
  34.     public function valid(): bool
  35.     {
  36.         return key($this->items) !== null;
  37.     }
  38.     public function count(): int
  39.     {
  40.         return count($this->items);
  41.     }
  42.     public function setCustomParameters(array $parameters): void
  43.     {
  44.         $this->customParameters $parameters;
  45.     }
  46.     /**
  47.      * @return mixed|null
  48.      */
  49.     public function getCustomParameter(string $name)
  50.     {
  51.         return $this->customParameters[$name] ?? null;
  52.     }
  53.     public function setCurrentPageNumber(int $pageNumber): void
  54.     {
  55.         $this->currentPageNumber $pageNumber;
  56.     }
  57.     public function getCurrentPageNumber(): int
  58.     {
  59.         return $this->currentPageNumber;
  60.     }
  61.     public function setItemNumberPerPage(int $numItemsPerPage): void
  62.     {
  63.         $this->numItemsPerPage $numItemsPerPage;
  64.     }
  65.     public function getItemNumberPerPage(): int
  66.     {
  67.         return $this->numItemsPerPage;
  68.     }
  69.     public function setTotalItemCount(int $numTotal): void
  70.     {
  71.         $this->totalCount $numTotal;
  72.     }
  73.     public function getTotalItemCount(): int
  74.     {
  75.         return $this->totalCount;
  76.     }
  77.     public function setPaginatorOptions(array $options): void
  78.     {
  79.         $this->paginatorOptions $options;
  80.     }
  81.     /**
  82.      * @return mixed|null
  83.      */
  84.     public function getPaginatorOption(string $name)
  85.     {
  86.         return $this->paginatorOptions[$name] ?? null;
  87.     }
  88.     public function setItems(iterable $items): void
  89.     {
  90.         $this->items $items;
  91.     }
  92.     public function getItems(): iterable
  93.     {
  94.         return $this->items;
  95.     }
  96.     /**
  97.      * @param string|int|float|bool|null $offset
  98.      */
  99.     public function offsetExists($offset): bool
  100.     {
  101.         if ($this->items instanceof \ArrayIterator) {
  102.             return array_key_exists($offsetiterator_to_array($this->items));
  103.         }
  104.         return array_key_exists($offset$this->items);
  105.     }
  106.     /**
  107.      * @param string|int|float|bool|null $offset
  108.      * @return mixed
  109.      */
  110.     public function offsetGet($offset)
  111.     {
  112.         return $this->items[$offset];
  113.     }
  114.     /**
  115.      * @param string|int|float|bool|null $offset
  116.      * @param mixed $value
  117.      */
  118.     public function offsetSet($offset$value): void
  119.     {
  120.         if (null === $offset) {
  121.             $this->items[] = $value;
  122.         } else {
  123.             $this->items[$offset] = $value;
  124.         }
  125.     }
  126.     /**
  127.      * @param string|int|float|bool|null $offset
  128.      */
  129.     public function offsetUnset($offset): void
  130.     {
  131.         unset($this->items[$offset]);
  132.     }
  133. }