Passed
Branch master (d24529)
by BENOIT
02:55
created
src/BenTools/Pager/Page.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     protected   $pager;
49 49
 
50 50
     public function __construct(Pager $pager, $iteration = 1) {
51
-        $this->pager        =    $pager;
52
-        $this->iteration    =    (int) $iteration;
51
+        $this->pager        = $pager;
52
+        $this->iteration    = (int) $iteration;
53 53
         $this->populate();
54 54
     }
55 55
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function getOffset() {
75 75
         if (!$this->offset)
76
-            $this->offset   =   ($this->getIndex() * $this->getPager()->getResultsPerPage());
76
+            $this->offset = ($this->getIndex() * $this->getPager()->getResultsPerPage());
77 77
         return $this->offset;
78 78
     }
79 79
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function getResultCount() {
85 85
         if (!$this->resultCount)
86
-            $this->resultCount   =   $this->isLastPage() ? $this->getPager()->getTotalResultCount() - $this->getOffset() : $this->getPager()->getResultsPerPage();
86
+            $this->resultCount = $this->isLastPage() ? $this->getPager()->getTotalResultCount() - $this->getOffset() : $this->getPager()->getResultsPerPage();
87 87
         return $this->resultCount;
88 88
     }
89 89
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function isFirstPage() {
95 95
         if (!$this->isFirstPage)
96
-            $this->isFirstPage    =    ($this->getIteration() == 1);
96
+            $this->isFirstPage = ($this->getIteration() == 1);
97 97
         return $this->isFirstPage;
98 98
     }
99 99
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function isLastPage() {
105 105
         if (!$this->isLastPage)
106
-            $this->isLastPage    =    ($this->getIteration() == $this->pager->getNbPages());
106
+            $this->isLastPage = ($this->getIteration() == $this->pager->getNbPages());
107 107
         return $this->isLastPage;
108 108
     }
109 109
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function isCurrentPage() {
115 115
         if (!$this->isCurrentPage)
116
-            $this->isCurrentPage    =    ($this->getIteration() == ($this->pager->getCurrentPageIteration()));
116
+            $this->isCurrentPage = ($this->getIteration() == ($this->pager->getCurrentPageIteration()));
117 117
         return $this->isCurrentPage;
118 118
     }
119 119
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function isPreviousPage() {
125 125
         if (!$this->isPreviousPage)
126
-            $this->isPreviousPage    =    ($this->getIteration() == ($this->pager->getCurrentPageIteration() - 1));
126
+            $this->isPreviousPage = ($this->getIteration() == ($this->pager->getCurrentPageIteration() - 1));
127 127
         return $this->isPreviousPage;
128 128
     }
129 129
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function isNextPage() {
135 135
         if (!$this->isNextPage)
136
-            $this->isNextPage    =    ($this->getIteration() == ($this->pager->getCurrentPageIteration() + 1));
136
+            $this->isNextPage = ($this->getIteration() == ($this->pager->getCurrentPageIteration() + 1));
137 137
         return $this->isNextPage;
138 138
     }
139 139
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             if (preg_match('#' . sprintf($this->pager->getRewriteString(), '([0-9]+)') . '#', (string) $this->pager->getUrl()))
172 172
                 $this->setUrl(new Url(preg_replace('#' . sprintf($this->pager->getRewriteString(), '([0-9]+)') . '#', sprintf($this->pager->getRewriteString(), $this->getIteration()), (string) $this->pager->getUrl())));
173 173
             else {
174
-                $url        =   clone $this->getPager()->getUrl();
174
+                $url = clone $this->getPager()->getUrl();
175 175
                 $this->setUrl($url->appendToPath(sprintf($this->getPager()->getRewriteString(), $this->getIteration())));
176 176
             }
177 177
 
Please login to merge, or discard this patch.
src/BenTools/Pager/Pager.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -36,44 +36,44 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class Pager implements \IteratorAggregate, \Countable, \ArrayAccess, \JsonSerializable {
38 38
 
39
-    const       DEFAULT_PAGE_CLASS      =   '\\BenTools\\Pager\\Page';
40
-    const       DEFAULT_QUERY_PARAM     =   'page';
41
-    const       DEFAULT_DELTA           =   1;
39
+    const       DEFAULT_PAGE_CLASS      = '\\BenTools\\Pager\\Page';
40
+    const       DEFAULT_QUERY_PARAM     = 'page';
41
+    const       DEFAULT_DELTA           = 1;
42 42
 
43 43
     /**
44 44
      * The class that will handle each page.
45 45
      * @var string
46 46
      */
47
-    protected   $pageClass              =   self::DEFAULT_PAGE_CLASS;
47
+    protected   $pageClass = self::DEFAULT_PAGE_CLASS;
48 48
 
49 49
     /**
50 50
      * @var int
51 51
      */
52
-    protected   $resultsPerPage         =   0;
52
+    protected   $resultsPerPage = 0;
53 53
 
54 54
     /**
55 55
      * The total results count, all pages included.
56 56
      * @var int
57 57
      */
58
-    protected   $totalResultCount       =   0;
58
+    protected   $totalResultCount = 0;
59 59
 
60 60
     /**
61 61
      * Current result count
62 62
      * @var int
63 63
      */
64
-    protected   $currentResultCount     =   0;
64
+    protected   $currentResultCount = 0;
65 65
 
66 66
     /**
67 67
      * The Query param to check in the query string
68 68
      * @var string
69 69
      */
70
-    protected   $queryParam             =   self::DEFAULT_QUERY_PARAM;
70
+    protected   $queryParam = self::DEFAULT_QUERY_PARAM;
71 71
 
72 72
     /**
73 73
      * A print_f compatible string if the page information is in a rewrite string instead of the query string
74 74
      * @var
75 75
      */
76
-    protected   $rewriteString          =   '';
76
+    protected   $rewriteString = '';
77 77
 
78 78
     /**
79 79
      * The current page iteration
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
      * How many pages to show on each side when too many pages are rendered
86 86
      * @var int
87 87
      */
88
-    protected   $delta                  =   self::DEFAULT_DELTA;
88
+    protected   $delta = self::DEFAULT_DELTA;
89 89
 
90 90
     /**
91 91
      * @var int
92 92
      */
93
-    protected   $nbPages                =   0;
93
+    protected   $nbPages = 0;
94 94
 
95 95
     /**
96 96
      * The current offset (useful for a LIMIT offset, max in a SQL clause)
97 97
      * @var int
98 98
      */
99
-    protected   $currentOffset          =   0;
99
+    protected   $currentOffset = 0;
100 100
 
101 101
     /**
102 102
      * The Url to begin with
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * The pages rendered by the object (if there's a delta and too many pages, not all pages will be shown)
109 109
      * @var array
110 110
      */
111
-    protected   $pages                  =   [];
111
+    protected   $pages = [];
112 112
 
113 113
     public function __construct($url = null, $resultsPerPage = null, $totalResultCount = null, $queryParam = self::DEFAULT_QUERY_PARAM, $rewriteString = null, $currentPageIteration = null, $delta = self::DEFAULT_DELTA) {
114 114
 
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
         if (!is_integer($this->totalResultCount))
275 275
             throw new PagerException(get_called_class() . "::setTotalResultCount has to be called first.");
276 276
 
277
-        $this->pages        =   [];
277
+        $this->pages = [];
278 278
 
279 279
         $this->setNbPages((int) ceil($this->getTotalResultCount() / $this->getResultsPerPage()));
280 280
 
281 281
         # Case of a delta, e.g. << 1 ... 6 [7] 8 ... 15 >>
282 282
         if ($this->getDelta()) {
283 283
 
284
-            $p              =   0;
284
+            $p              = 0;
285 285
 
286 286
             # Add first page, current page and last page
287
-            $this->pages[]  =   $this->getPageInstance(1);
288
-            $this->pages[]  =   $this->getPageInstance($this->getCurrentPageIteration());
289
-            $this->pages[]  =   $this->getPageInstance($this->getNbPages());
287
+            $this->pages[]  = $this->getPageInstance(1);
288
+            $this->pages[]  = $this->getPageInstance($this->getCurrentPageIteration());
289
+            $this->pages[]  = $this->getPageInstance($this->getNbPages());
290 290
 
291 291
             # Calculate delta
292 292
             for ($i = 1; $i <= $this->getDelta(); $i++) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         }
314 314
         else {
315 315
             for ($i = 1; $i <= $this->getNbPages(); $i++)
316
-                $this->pages[]  =   $this->getPageInstance($i);
316
+                $this->pages[] = $this->getPageInstance($i);
317 317
         }
318 318
         $this->pages = array_unique((array) $this->pages);
319 319
         sort($this->pages);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      * @return PageInterface
468 468
      */
469 469
     public function getPageInstance($iteration) {
470
-        $class  =   $this->pageClass;
470
+        $class = $this->pageClass;
471 471
         return new $class($this, (int) $iteration);
472 472
     }
473 473
 
Please login to merge, or discard this patch.