@@ -106,7 +106,7 @@ |
||
| 106 | 106 | * |
| 107 | 107 | * @API |
| 108 | 108 | * @param array $query query like $_GET |
| 109 | - * @param null $path path info |
|
| 109 | + * @param string $path path info |
|
| 110 | 110 | * @return Pager |
| 111 | 111 | */ |
| 112 | 112 | public function withQuery(array $query, $path = null) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->pagerKey => 1, |
| 71 | 71 | $this->limitKey => 20 |
| 72 | 72 | ]; |
| 73 | - $this->inputObject = $inputObject; |
|
| 73 | + $this->inputObject = $inputObject; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public static function forge($name = '', array $default, $inputObject = null) |
| 83 | 83 | { |
| 84 | 84 | $self = new self($default, $inputObject); |
| 85 | - $self->name = $name ?: 'pager-' . $name; |
|
| 85 | + $self->name = $name ?: 'pager-'.$name; |
|
| 86 | 86 | |
| 87 | 87 | return $self; |
| 88 | 88 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | private function secureInput(array $query) |
| 159 | 159 | { |
| 160 | - $secure = $this->validator ?: function (&$v) { |
|
| 160 | + $secure = $this->validator ?: function(&$v) { |
|
| 161 | 161 | if (!is_string($v) && !is_numeric($v)) { |
| 162 | 162 | $v = ''; |
| 163 | 163 | } elseif (strpos($v, "\0") !== false) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | private function setSessionName($pathInfo) |
| 209 | 209 | { |
| 210 | 210 | $this->path = $pathInfo; |
| 211 | - $this->name = $this->name ?: 'pager-' . md5($pathInfo); |
|
| 211 | + $this->name = $this->name ?: 'pager-'.md5($pathInfo); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -76,6 +76,9 @@ |
||
| 76 | 76 | return "<li><a href=\"{$p->getUrl()}\" >{$label}</a></li>\n"; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | + /** |
|
| 80 | + * @param string $label |
|
| 81 | + */ |
|
| 79 | 82 | private function liLabel(Page $p, $label) |
| 80 | 83 | { |
| 81 | 84 | if ($p->isCurrent()) { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | return $this->path; |
| 187 | 187 | } |
| 188 | 188 | $page = (int)$page; |
| 189 | - return $this->path . '?' . $this->pagerKey . '=' . $page; |
|
| 189 | + return $this->path.'?'.$this->pagerKey.'='.$page; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function getPagination() |
| 196 | 196 | { |
| 197 | - $paginate = $this->paginate ? $this->paginate->setInputs($this): Paginate::forge($this); |
|
| 197 | + $paginate = $this->paginate ? $this->paginate->setInputs($this) : Paginate::forge($this); |
|
| 198 | 198 | |
| 199 | 199 | return $paginate; |
| 200 | 200 | } |
@@ -30,8 +30,8 @@ |
||
| 30 | 30 | public function __construct($key, $currPage, $page) |
| 31 | 31 | { |
| 32 | 32 | $this->pagerKey = $key; |
| 33 | - $this->currPage = (int) $currPage; |
|
| 34 | - $this->page = (int) $page; |
|
| 33 | + $this->currPage = (int)$currPage; |
|
| 34 | + $this->page = (int)$page; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function getIterator() |
| 94 | 94 | { |
| 95 | 95 | $pages = $this->calcPageList(); |
| 96 | - foreach($pages as $p) { |
|
| 96 | + foreach ($pages as $p) { |
|
| 97 | 97 | yield $p; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | private function calcStart() |
| 126 | 126 | { |
| 127 | - $half = (int) ($this->numLinks / 2); |
|
| 127 | + $half = (int)($this->numLinks / 2); |
|
| 128 | 128 | $start = max($this->currPage - $half, $this->firstPage + 1); |
| 129 | 129 | $maybe = max($this->lastPage - 1 - $this->numLinks, $this->firstPage + 1); |
| 130 | 130 | $start = min($start, $maybe); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | private function calcLast() |
| 153 | 153 | { |
| 154 | - $numLinks = $this->numLinks - 1 + ($this->getExtraStart() ? 0: 1); |
|
| 154 | + $numLinks = $this->numLinks - 1 + ($this->getExtraStart() ? 0 : 1); |
|
| 155 | 155 | $last = min($this->calcStart() + $numLinks, $this->lastPage - 1); |
| 156 | 156 | return $last; |
| 157 | 157 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function __toString() |
| 218 | 218 | { |
| 219 | - $toHtml = $this->toHtml ? $this->toHtml->setPaginate($this): new ToBootstrap3($this); |
|
| 219 | + $toHtml = $this->toHtml ? $this->toHtml->setPaginate($this) : new ToBootstrap3($this); |
|
| 220 | 220 | return $toHtml->__toString(); |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | \ No newline at end of file |