Passed
Push — main ( 957ef0...483b9f )
by Thierry
04:08
created
jaxon-core/src/App/View/ViewRenderer.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function addNamespaces(Config $xAppConfig): void
99 99
     {
100
-        if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
100
+        if (empty($aNamespaces = $xAppConfig->getOptionNames('views')))
101 101
         {
102 102
             return;
103 103
         }
104 104
 
105 105
         $sPackage = $xAppConfig->getOption('package', '');
106
-        foreach($aNamespaces as $sNamespace => $sOption)
106
+        foreach ($aNamespaces as $sNamespace => $sOption)
107 107
         {
108 108
             // Save the namespace
109 109
             $aNamespace = $xAppConfig->getOption($sOption);
110 110
             $aNamespace['package'] = $sPackage;
111
-            if(!isset($aNamespace['renderer']))
111
+            if (!isset($aNamespace['renderer']))
112 112
             {
113 113
                 $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
114 114
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
148 148
                 return $aOptions['renderer'] === $sId;
149 149
             });
150
-            foreach($aNamespaces as $sName => $aOptions)
150
+            foreach ($aNamespaces as $sName => $aOptions)
151 151
             {
152 152
                 $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
153 153
             }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
182 182
     {
183
-        if(!isset($this->aNamespaces[$sNamespace]))
183
+        if (!isset($this->aNamespaces[$sNamespace]))
184 184
         {
185 185
             return null;
186 186
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function store(): Store
207 207
     {
208
-        if(!$this->xStore)
208
+        if (!$this->xStore)
209 209
         {
210 210
             $this->xStore = new Store();
211 211
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function shareValues(array $aValues): ViewRenderer
251 251
     {
252
-        foreach($aValues as $sName => $xValue)
252
+        foreach ($aValues as $sName => $xValue)
253 253
         {
254 254
             $this->share($sName, $xValue);
255 255
         }
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
         $sNamespace = $this->sDefaultNamespace;
274 274
         // Get the namespace from the view name
275 275
         $nSeparatorPosition = strrpos($sViewName, '::');
276
-        if($nSeparatorPosition !== false)
276
+        if ($nSeparatorPosition !== false)
277 277
         {
278 278
             $sNamespace = substr($sViewName, 0, $nSeparatorPosition);
279 279
             $sViewName = substr($sViewName, $nSeparatorPosition + 2);
280 280
         }
281 281
 
282 282
         $xRenderer = $this->getNamespaceRenderer($sNamespace);
283
-        if(!$xRenderer)
283
+        if (!$xRenderer)
284 284
         {
285 285
             // Cannot render a view if there's no renderer corresponding to the namespace.
286 286
             return $this->xEmptyStore;
Please login to merge, or discard this patch.
Switch Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 
14 14
 class ViewRenderer
15 15
 {
16
-    /**
16
+/**
17 17
      * @var Container
18 18
      */
19
-    protected $di;
19
+protected $di;
20 20
 
21
-    /**
21
+/**
22 22
      * The view data store
23 23
      *
24 24
      * @var Store|null
25 25
      */
26
-    protected $xStore = null;
26
+protected $xStore = null;
27 27
 
28
-    /**
28
+/**
29 29
      * The view data store
30 30
      *
31 31
      * @var Store
32 32
      */
33
-    protected $xEmptyStore = null;
33
+protected $xEmptyStore = null;
34 34
 
35
-    /**
35
+/**
36 36
      * The view namespaces
37 37
      *
38 38
      * @var array
39 39
      */
40
-    protected $aNamespaces = [];
40
+protected $aNamespaces = [];
41 41
 
42
-    /**
42
+/**
43 43
      * The default namespace
44 44
      *
45 45
      * @var string
46 46
      */
47
-    protected $sDefaultNamespace = 'jaxon';
47
+protected $sDefaultNamespace = 'jaxon';
48 48
 
49
-    /**
49
+/**
50 50
      * The view global data
51 51
      *
52 52
      * @var array
53 53
      */
54
-    protected $aViewData = [];
54
+protected $aViewData = [];
55 55
 
56
-    /**
56
+/**
57 57
      * The class constructor
58 58
      *
59 59
      * @param Container $di
60 60
      */
61
-    public function __construct(Container $di)
62
-    {
63
-        $this->di = $di;
64
-        $this->xEmptyStore = new Store();
65
-    }
61
+public function __construct(Container $di)
62
+{
63
+$this->di = $di;
64
+$this->xEmptyStore = new Store();
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * Add a view namespace, and set the corresponding renderer.
69 69
      *
70 70
      * @param string $sNamespace    The namespace name
@@ -74,59 +74,59 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return void
76 76
      */
77
-    public function addNamespace(string $sNamespace, string $sDirectory,
78
-        string $sExtension, string $sRenderer): void
79
-    {
80
-        $aNamespace = [
81
-            'directory' => $sDirectory,
82
-            'extension' => $sExtension,
83
-            'renderer' => $sRenderer,
84
-        ];
85
-        $this->aNamespaces[$sNamespace] = $aNamespace;
86
-    }
77
+public function addNamespace(string $sNamespace, string $sDirectory,
78
+string $sExtension, string $sRenderer): void
79
+{
80
+$aNamespace = [
81
+'directory' => $sDirectory,
82
+'extension' => $sExtension,
83
+'renderer' => $sRenderer,
84
+];
85
+$this->aNamespaces[$sNamespace] = $aNamespace;
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * Set the view namespaces.
90 90
      *
91 91
      * @param Config $xAppConfig    The config options provided in the library
92 92
      *
93 93
      * @return void
94 94
      */
95
-    public function addNamespaces(Config $xAppConfig): void
96
-    {
97
-        if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
98
-        {
99
-            return;
100
-        }
95
+public function addNamespaces(Config $xAppConfig): void
96
+{
97
+if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
98
+{
99
+return;
100
+}
101 101
 
102
-        $sPackage = $xAppConfig->getOption('package', '');
103
-        foreach($aNamespaces as $sNamespace => $sOption)
104
-        {
105
-            // Save the namespace
106
-            $aNamespace = $xAppConfig->getOption($sOption);
107
-            $aNamespace['package'] = $sPackage;
108
-            if(!isset($aNamespace['renderer']))
109
-            {
110
-                $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
111
-            }
112
-            $this->aNamespaces[$sNamespace] = $aNamespace;
113
-        }
114
-    }
102
+$sPackage = $xAppConfig->getOption('package', '');
103
+foreach($aNamespaces as $sNamespace => $sOption)
104
+{
105
+// Save the namespace
106
+$aNamespace = $xAppConfig->getOption($sOption);
107
+$aNamespace['package'] = $sPackage;
108
+if(!isset($aNamespace['renderer']))
109
+{
110
+    $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
111
+}
112
+$this->aNamespaces[$sNamespace] = $aNamespace;
113
+}
114
+}
115 115
 
116
-    /**
116
+/**
117 117
      * Get the view renderer
118 118
      *
119 119
      * @param string $sId    The unique identifier of the view renderer
120 120
      *
121 121
      * @return ViewInterface
122 122
      */
123
-    public function getRenderer(string $sId): ViewInterface
124
-    {
125
-        // Return the view renderer with the given id
126
-        return $this->di->g("jaxon.app.view.$sId");
127
-    }
123
+public function getRenderer(string $sId): ViewInterface
124
+{
125
+// Return the view renderer with the given id
126
+return $this->di->g("jaxon.app.view.$sId");
127
+}
128 128
 
129
-    /**
129
+/**
130 130
      * Add a view renderer with an id
131 131
      *
132 132
      * @param string $sId    The unique identifier of the view renderer
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
      *
135 135
      * @return void
136 136
      */
137
-    public function addRenderer(string $sId, Closure $xClosure): void
138
-    {
139
-        // Return the initialized view renderer
140
-        $this->di->set("jaxon.app.view.$sId", function($di) use($sId, $xClosure) {
141
-            // Get the defined renderer
142
-            $xRenderer = $xClosure($di);
143
-            // Init the renderer with the template namespaces
144
-            $aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
145
-                return $aOptions['renderer'] === $sId;
146
-            });
147
-            foreach($aNamespaces as $sName => $aOptions)
148
-            {
149
-                $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
150
-            }
151
-            return $xRenderer;
152
-        });
153
-    }
137
+public function addRenderer(string $sId, Closure $xClosure): void
138
+{
139
+// Return the initialized view renderer
140
+$this->di->set("jaxon.app.view.$sId", function($di) use($sId, $xClosure) {
141
+// Get the defined renderer
142
+$xRenderer = $xClosure($di);
143
+// Init the renderer with the template namespaces
144
+$aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
145
+    return $aOptions['renderer'] === $sId;
146
+});
147
+foreach($aNamespaces as $sName => $aOptions)
148
+{
149
+    $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
150
+}
151
+return $xRenderer;
152
+});
153
+}
154 154
 
155
-    /**
155
+/**
156 156
      * Add a view renderer with an id
157 157
      *
158 158
      * @param string $sId    The unique identifier of the view renderer
@@ -161,55 +161,55 @@  discard block
 block discarded – undo
161 161
      *
162 162
      * @return void
163 163
      */
164
-    public function setDefaultRenderer(string $sId, string $sExtension, Closure $xClosure): void
165
-    {
166
-        $this->setDefaultNamespace($sId);
167
-        $this->addNamespace($sId, '', $sExtension, $sId);
168
-        $this->addRenderer($sId, $xClosure);
169
-    }
164
+public function setDefaultRenderer(string $sId, string $sExtension, Closure $xClosure): void
165
+{
166
+$this->setDefaultNamespace($sId);
167
+$this->addNamespace($sId, '', $sExtension, $sId);
168
+$this->addRenderer($sId, $xClosure);
169
+}
170 170
 
171
-    /**
171
+/**
172 172
      * Get the view renderer for a given namespace
173 173
      *
174 174
      * @param string $sNamespace    The namespace name
175 175
      *
176 176
      * @return ViewInterface|null
177 177
      */
178
-    public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
179
-    {
180
-        if(!isset($this->aNamespaces[$sNamespace]))
181
-        {
182
-            return null;
183
-        }
184
-        // Return the view renderer with the configured id
185
-        return $this->getRenderer($this->aNamespaces[$sNamespace]['renderer']);
186
-    }
178
+public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
179
+{
180
+if(!isset($this->aNamespaces[$sNamespace]))
181
+{
182
+return null;
183
+}
184
+// Return the view renderer with the configured id
185
+return $this->getRenderer($this->aNamespaces[$sNamespace]['renderer']);
186
+}
187 187
 
188
-    /**
188
+/**
189 189
      * Set the default namespace
190 190
      *
191 191
      * @param string $sDefaultNamespace
192 192
      */
193
-    public function setDefaultNamespace(string $sDefaultNamespace): void
194
-    {
195
-        $this->sDefaultNamespace = $sDefaultNamespace;
196
-    }
193
+public function setDefaultNamespace(string $sDefaultNamespace): void
194
+{
195
+$this->sDefaultNamespace = $sDefaultNamespace;
196
+}
197 197
 
198
-    /**
198
+/**
199 199
      * Get the current store or create a new store
200 200
      *
201 201
      * @return Store
202 202
      */
203
-    protected function store(): Store
204
-    {
205
-        if(!$this->xStore)
206
-        {
207
-            $this->xStore = new Store();
208
-        }
209
-        return $this->xStore;
210
-    }
203
+protected function store(): Store
204
+{
205
+if(!$this->xStore)
206
+{
207
+$this->xStore = new Store();
208
+}
209
+return $this->xStore;
210
+}
211 211
 
212
-    /**
212
+/**
213 213
      * Make a piece of data available for the rendered view
214 214
      *
215 215
      * @param string $sName    The data name
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
      *
218 218
      * @return ViewRenderer
219 219
      */
220
-    public function set(string $sName, $xValue): ViewRenderer
221
-    {
222
-        $this->store()->with($sName, $xValue);
223
-        return $this;
224
-    }
220
+public function set(string $sName, $xValue): ViewRenderer
221
+{
222
+$this->store()->with($sName, $xValue);
223
+return $this;
224
+}
225 225
 
226
-    /**
226
+/**
227 227
      * Make a piece of data available for all views
228 228
      *
229 229
      * @param string $sName    The data name
@@ -231,29 +231,29 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return ViewRenderer
233 233
      */
234
-    public function share(string $sName, $xValue): ViewRenderer
235
-    {
236
-        $this->aViewData[$sName] = $xValue;
237
-        return $this;
238
-    }
234
+public function share(string $sName, $xValue): ViewRenderer
235
+{
236
+$this->aViewData[$sName] = $xValue;
237
+return $this;
238
+}
239 239
 
240
-    /**
240
+/**
241 241
      * Make an array of data available for all views
242 242
      *
243 243
      * @param array $aValues    The data values
244 244
      *
245 245
      * @return ViewRenderer
246 246
      */
247
-    public function shareValues(array $aValues): ViewRenderer
248
-    {
249
-        foreach($aValues as $sName => $xValue)
250
-        {
251
-            $this->share($sName, $xValue);
252
-        }
253
-        return $this;
254
-    }
247
+public function shareValues(array $aValues): ViewRenderer
248
+{
249
+foreach($aValues as $sName => $xValue)
250
+{
251
+$this->share($sName, $xValue);
252
+}
253
+return $this;
254
+}
255 255
 
256
-    /**
256
+/**
257 257
      * Render a view using a store
258 258
      *
259 259
      * The store returned by this function will later be used with the make() method to render the view.
@@ -263,32 +263,32 @@  discard block
 block discarded – undo
263 263
      *
264 264
      * @return Store   A store populated with the view data
265 265
      */
266
-    public function render(string $sViewName, array $aViewData = []): Store
267
-    {
268
-        $xStore = $this->store();
269
-        // Get the default view namespace
270
-        $sNamespace = $this->sDefaultNamespace;
271
-        // Get the namespace from the view name
272
-        $nSeparatorPosition = strrpos($sViewName, '::');
273
-        if($nSeparatorPosition !== false)
274
-        {
275
-            $sNamespace = substr($sViewName, 0, $nSeparatorPosition);
276
-            $sViewName = substr($sViewName, $nSeparatorPosition + 2);
277
-        }
266
+public function render(string $sViewName, array $aViewData = []): Store
267
+{
268
+$xStore = $this->store();
269
+// Get the default view namespace
270
+$sNamespace = $this->sDefaultNamespace;
271
+// Get the namespace from the view name
272
+$nSeparatorPosition = strrpos($sViewName, '::');
273
+if($nSeparatorPosition !== false)
274
+{
275
+$sNamespace = substr($sViewName, 0, $nSeparatorPosition);
276
+$sViewName = substr($sViewName, $nSeparatorPosition + 2);
277
+}
278 278
 
279
-        $xRenderer = $this->getNamespaceRenderer($sNamespace);
280
-        if(!$xRenderer)
281
-        {
282
-            // Cannot render a view if there's no renderer corresponding to the namespace.
283
-            return $this->xEmptyStore;
284
-        }
279
+$xRenderer = $this->getNamespaceRenderer($sNamespace);
280
+if(!$xRenderer)
281
+{
282
+// Cannot render a view if there's no renderer corresponding to the namespace.
283
+return $this->xEmptyStore;
284
+}
285 285
 
286
-        $xStore->setData(array_merge($this->aViewData, $aViewData))
287
-            ->setView($xRenderer, $sNamespace, $sViewName);
286
+$xStore->setData(array_merge($this->aViewData, $aViewData))
287
+->setView($xRenderer, $sNamespace, $sViewName);
288 288
 
289
-        // Set the store to null so a new store will be created for the next view.
290
-        $this->xStore = null;
291
-        // Return the store
292
-        return $xStore;
293
-    }
289
+// Set the store to null so a new store will be created for the next view.
290
+$this->xStore = null;
291
+// Return the store
292
+return $xStore;
293
+}
294 294
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/PageComponent.php 1 patch
Switch Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@
 block discarded – undo
6 6
 
7 7
 abstract class PageComponent extends NodeComponent
8 8
 {
9
-    /**
9
+/**
10 10
      * The current page number.
11 11
      *
12 12
      * @var int
13 13
      */
14
-    private int $currentPage = 1;
14
+private int $currentPage = 1;
15 15
 
16
-    /**
16
+/**
17 17
      * Get the total number of items to paginate.
18 18
      *
19 19
      * @return int
20 20
      */
21
-    abstract protected function count(): int;
21
+abstract protected function count(): int;
22 22
 
23
-    /**
23
+/**
24 24
      * Get the max number of items per page.
25 25
      *
26 26
      * @return int
27 27
      */
28
-    abstract protected function limit(): int;
28
+abstract protected function limit(): int;
29 29
 
30
-    /**
30
+/**
31 31
      * Get the paginator for the component.
32 32
      *
33 33
      * @param int $pageNumber
34 34
      *
35 35
      * @return Paginator
36 36
      */
37
-    protected function paginator(int $pageNumber): Paginator
38
-    {
39
-        return $this->cl(Component\Pagination::class)
40
-            // Use the js class name as component item identifier.
41
-            ->item($this->rq()->_class())
42
-            ->paginator($pageNumber > 0 ? $pageNumber : 1, $this->limit(), $this->count())
43
-            // This callback will receive the final value of the current page number.
44
-            ->page(function(int $currentPage) {
45
-                $this->currentPage = $currentPage;
46
-            });
47
-    }
37
+protected function paginator(int $pageNumber): Paginator
38
+{
39
+return $this->cl(Component\Pagination::class)
40
+// Use the js class name as component item identifier.
41
+->item($this->rq()->_class())
42
+->paginator($pageNumber > 0 ? $pageNumber : 1, $this->limit(), $this->count())
43
+// This callback will receive the final value of the current page number.
44
+->page(function(int $currentPage) {
45
+    $this->currentPage = $currentPage;
46
+});
47
+}
48 48
 
49
-    /**
49
+/**
50 50
      * Get the current page number
51 51
      *
52 52
      * @return int
53 53
      */
54
-    protected function currentPage(): int
55
-    {
56
-        return $this->currentPage;
57
-    }
54
+protected function currentPage(): int
55
+{
56
+return $this->currentPage;
57
+}
58 58
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/PageDatabagTrait.php 2 patches
Switch Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -6,81 +6,81 @@
 block discarded – undo
6 6
 
7 7
 trait PageDatabagTrait
8 8
 {
9
-    /**
9
+/**
10 10
      * The current page number.
11 11
      *
12 12
      * @var int
13 13
      */
14
-    private int $currentPage = 1;
14
+private int $currentPage = 1;
15 15
 
16
-    /**
16
+/**
17 17
      * Get the pagination databag name.
18 18
      *
19 19
      * @return string
20 20
      */
21
-    abstract protected function bagName(): string;
21
+abstract protected function bagName(): string;
22 22
 
23
-    /**
23
+/**
24 24
      * Get the pagination databag attribute.
25 25
      *
26 26
      * @return string
27 27
      */
28
-    abstract protected function bagAttr(): string;
28
+abstract protected function bagAttr(): string;
29 29
 
30
-    /**
30
+/**
31 31
      * Get the page number.
32 32
      *
33 33
      * @param int $pageNumber
34 34
      *
35 35
      * @return int
36 36
      */
37
-    private function getPageNumber(int $pageNumber): int
38
-    {
39
-        // If no page number is provided, then get the value from the databag.
40
-        return $pageNumber > 0 ? $pageNumber :
41
-            (int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
42
-    }
37
+private function getPageNumber(int $pageNumber): int
38
+{
39
+// If no page number is provided, then get the value from the databag.
40
+return $pageNumber > 0 ? $pageNumber :
41
+(int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
42
+}
43 43
 
44
-    /**
44
+/**
45 45
      * Set the page number.
46 46
      *
47 47
      * @param int $currentPage
48 48
      *
49 49
      * @return void
50 50
      */
51
-    private function setCurrentPage(int $currentPage): void
52
-    {
53
-        // Save the current page in the databag.
54
-        $this->bag($this->bagName())->set($this->bagAttr(), $currentPage);
55
-        $this->currentPage = $currentPage;
56
-    }
51
+private function setCurrentPage(int $currentPage): void
52
+{
53
+// Save the current page in the databag.
54
+$this->bag($this->bagName())->set($this->bagAttr(), $currentPage);
55
+$this->currentPage = $currentPage;
56
+}
57 57
 
58
-    /**
58
+/**
59 59
      * Get the paginator for the component.
60 60
      *
61 61
      * @param int $pageNumber
62 62
      *
63 63
      * @return Paginator
64 64
      */
65
-    protected function paginator(int $pageNumber): Paginator
66
-    {
67
-        return $this->cl(Component\Pagination::class)
68
-            // Use the js class name as component item identifier.
69
-            ->item($this->rq()->_class())
70
-            ->paginator($this->getPageNumber($pageNumber), $this->limit(), $this->count())
71
-            // This callback will receive the final value of the current page number.
72
-            ->page(function(int $currentPage) {
73
-                $this->setCurrentPage($currentPage);
74
-            });
75
-    }
65
+protected function paginator(int $pageNumber): Paginator
66
+{
67
+return $this->cl(Component\Pagination::class)
68
+// Use the js class name as component item identifier.
69
+->item($this->rq()->_class())
70
+->paginator($this->getPageNumber($pageNumber), $this->limit(), $this->count())
71
+// This callback will receive the final value of the current page number.
72
+->page(function(int $currentPage) {
73
+    $this->setCurrentPage($currentPage);
74
+});
75
+}
76 76
 
77
-    /**
77
+/**
78 78
      * Get the current page number
79 79
      *
80 80
      * @return int
81 81
      */
82
-    protected function currentPage(): int
83
-    {
84
-        return $this->currentPage;
85
-    }
82
+protected function currentPage(): int
83
+{
84
+return $this->currentPage;
85
+}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
     private function getPageNumber(int $pageNumber): int
38 38
     {
39 39
         // If no page number is provided, then get the value from the databag.
40
-        return $pageNumber > 0 ? $pageNumber :
41
-            (int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
40
+        return $pageNumber > 0 ? $pageNumber : (int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
42 41
     }
43 42
 
44 43
     /**
Please login to merge, or discard this patch.
jaxon-core/src/globals.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function cl(string $sClassName): mixed
34 34
 {
35
-    return \Jaxon\cl($sClassName);
35
+return \Jaxon\cl($sClassName);
36 36
 }
37 37
 
38 38
 /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function rq(string $sClassName = ''): JxnCall
46 46
 {
47
-    return \Jaxon\rq($sClassName);
47
+return \Jaxon\rq($sClassName);
48 48
 }
49 49
 
50 50
 /**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function jo(string $sJsObject = ''): JsObjectCall
58 58
 {
59
-    return \Jaxon\jo($sJsObject);
59
+return \Jaxon\jo($sJsObject);
60 60
 }
61 61
 
62 62
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function jq(string $sPath = '', $xContext = null): JqSelectorCall
71 71
 {
72
-    return \Jaxon\jq($sPath, $xContext);
72
+return \Jaxon\jq($sPath, $xContext);
73 73
 }
74 74
 
75 75
 /**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function je(string $sElementId = ''): JsSelectorCall
83 83
 {
84
-    return \Jaxon\je($sElementId);
84
+return \Jaxon\je($sElementId);
85 85
 }
86 86
 
87 87
 /**
@@ -91,5 +91,5 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function attr(): HtmlAttrHelper
93 93
 {
94
-    return \Jaxon\attr();
94
+return \Jaxon\attr();
95 95
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrAjaxMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         // and the other classes will get this request from there.
65 65
         $this->di->val(ServerRequestInterface::class, $request);
66 66
 
67
-        if(!$this->xRequestHandler->canProcessRequest())
67
+        if (!$this->xRequestHandler->canProcessRequest())
68 68
         {
69 69
             // Unable to find a plugin to process the request
70 70
             return $handler->handle($request);
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrRequestHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
         // and the other classes will get this request from there.
73 73
         $this->di->val(ServerRequestInterface::class, $request);
74 74
 
75
-        if(!$this->xRequestHandler->canProcessRequest())
75
+        if (!$this->xRequestHandler->canProcessRequest())
76 76
         {
77 77
             // Unable to find a plugin to process the request
78 78
             throw new RequestException($this->xTranslator->trans('errors.request.plugin'));
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/CallbackManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function popBootCallbacks(): array
100 100
     {
101
-        if(empty($this->aBootCallbacks))
101
+        if (empty($this->aBootCallbacks))
102 102
         {
103 103
             return [];
104 104
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     private function getExceptionCallbacks(Exception $xException): array
118 118
     {
119 119
         $aExceptionCallbacks = [];
120
-        foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks)
120
+        foreach ($this->aExceptionCallbacks as $sExClass => $aCallbacks)
121 121
         {
122
-            if(is_a($xException, $sExClass))
122
+            if (is_a($xException, $sExClass))
123 123
             {
124 124
                 $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks);
125 125
             }
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function error(callable $xCallable, string $sExClass = ''): CallbackManager
191 191
     {
192
-        if($sExClass === '' || $sExClass === Exception::class)
192
+        if ($sExClass === '' || $sExClass === Exception::class)
193 193
         {
194 194
             $this->aErrorCallbacks[] = $xCallable;
195 195
             return $this;
196 196
         }
197 197
         // Callback for a given exception class
198
-        if(isset($this->aExceptionCallbacks[$sExClass]))
198
+        if (isset($this->aExceptionCallbacks[$sExClass]))
199 199
         {
200 200
             $this->aExceptionCallbacks[$sExClass][] = $xCallable;
201 201
             return $this;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     private function executeCallbacks(array $aCallbacks, array $aParameters): void
238 238
     {
239
-        foreach($aCallbacks as $xCallback)
239
+        foreach ($aCallbacks as $xCallback)
240 240
         {
241 241
             $this->executeCallback($xCallback, $aParameters);
242 242
         }
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     public function onBefore(Target $xTarget, bool &$bEndRequest): void
267 267
     {
268 268
         // Call the user defined callback
269
-        foreach($this->aBeforeCallbacks as $xCallback)
269
+        foreach ($this->aBeforeCallbacks as $xCallback)
270 270
         {
271 271
             $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]);
272
-            if($bEndRequest)
272
+            if ($bEndRequest)
273 273
             {
274 274
                 return;
275 275
             }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $aExceptionCallbacks = $this->getExceptionCallbacks($xException);
318 318
         $this->executeCallbacks($aExceptionCallbacks, [$xException]);
319
-        if(count($aExceptionCallbacks) > 0)
319
+        if (count($aExceptionCallbacks) > 0)
320 320
         {
321 321
             // Do not throw the exception if a custom handler is defined
322 322
             return;
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/RequestHandler.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -142,8 +142,7 @@
 block discarded – undo
142 142
         {
143 143
             $this->xResponseManager->error($e->getMessage());
144 144
             $this->xCallbackManager->onInvalid($e);
145
-        }
146
-        catch(Exception $e)
145
+        } catch(Exception $e)
147 146
         {
148 147
             $this->xResponseManager->error($e->getMessage());
149 148
             $this->xCallbackManager->onError($e);
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function canProcessRequest(): bool
62 62
     {
63 63
         // Return true if the request plugin was already found
64
-        if($this->xRequestPlugin !== null)
64
+        if ($this->xRequestPlugin !== null)
65 65
         {
66 66
             return true;
67 67
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $xRequest = $this->di->getRequest();
71 71
 
72 72
         // Find a plugin to process the request
73
-        foreach($this->xPluginManager->getRequestHandlers() as $sClassName)
73
+        foreach ($this->xPluginManager->getRequestHandlers() as $sClassName)
74 74
         {
75
-            if($sClassName::canProcessRequest($xRequest))
75
+            if ($sClassName::canProcessRequest($xRequest))
76 76
             {
77 77
                 $this->xRequestPlugin = $this->di->g($sClassName);
78 78
                 $xTarget = $this->xRequestPlugin->setTarget($xRequest);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     private function _processRequest(): void
93 93
     {
94 94
         // Process the request
95
-        if($this->xRequestPlugin !== null)
95
+        if ($this->xRequestPlugin !== null)
96 96
         {
97 97
             $this->xRequestPlugin->processRequest();
98 98
             // Process the databag
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         $this->di->getBootstrap()->onBoot();
113 113
 
114 114
         // Check if there is a plugin to process this request
115
-        if(!$this->canProcessRequest())
115
+        if (!$this->canProcessRequest())
116 116
         {
117 117
             return;
118 118
         }
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
         {
122 122
             $bEndRequest = false;
123 123
             // Handle before processing event
124
-            if($this->xRequestPlugin !== null)
124
+            if ($this->xRequestPlugin !== null)
125 125
             {
126 126
                 $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest);
127 127
             }
128
-            if($bEndRequest)
128
+            if ($bEndRequest)
129 129
             {
130 130
                 return;
131 131
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             $this->_processRequest();
134 134
 
135 135
             // Handle after processing event
136
-            if($this->xRequestPlugin !== null)
136
+            if ($this->xRequestPlugin !== null)
137 137
             {
138 138
                 $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest);
139 139
             }
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         // An exception was thrown while processing the request.
142 142
         // The request missed the corresponding handler function,
143 143
         // or an error occurred while attempting to execute the handler.
144
-        catch(RequestException $e)
144
+        catch (RequestException $e)
145 145
         {
146 146
             $this->xResponseManager->error($e->getMessage());
147 147
             $this->xCallbackManager->onInvalid($e);
148 148
         }
149
-        catch(Exception $e)
149
+        catch (Exception $e)
150 150
         {
151 151
             $this->xResponseManager->error($e->getMessage());
152 152
             $this->xCallbackManager->onError($e);
Please login to merge, or discard this patch.
jaxon-core/src/Script/Action/Func.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
      */
32 32
     public function withPage(): self
33 33
     {
34
-        foreach($this->aArguments as $xArgument)
34
+        foreach ($this->aArguments as $xArgument)
35 35
         {
36
-            if(TypedValue::isPage($xArgument))
36
+            if (TypedValue::isPage($xArgument))
37 37
             {
38 38
                 return $this;
39 39
             }
Please login to merge, or discard this patch.