@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function addCodeGenerator(string $sClassName, int $nPriority) |
117 | 117 | { |
118 | - while(isset($this->aCodeGenerators[$nPriority])) |
|
118 | + while (isset($this->aCodeGenerators[$nPriority])) |
|
119 | 119 | { |
120 | 120 | $nPriority++; |
121 | 121 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | private function generatePluginCodes(string $sClassName) |
159 | 159 | { |
160 | 160 | $xGenerator = $this->di->g($sClassName); |
161 | - if(!is_subclass_of($xGenerator, Plugin::class) || $this->xAssetManager->shallIncludeAssets($xGenerator)) |
|
161 | + if (!is_subclass_of($xGenerator, Plugin::class) || $this->xAssetManager->shallIncludeAssets($xGenerator)) |
|
162 | 162 | { |
163 | 163 | // HTML tags for CSS |
164 | 164 | $this->sCss = trim($this->sCss) . "\n" . trim($xGenerator->getCss(), " \n"); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | // Javascript code |
169 | 169 | $this->sJsScript = trim($this->sJsScript) . "\n\n" . trim($xGenerator->getScript(), " \n"); |
170 | - if($xGenerator->readyEnabled()) |
|
170 | + if ($xGenerator->readyEnabled()) |
|
171 | 171 | { |
172 | 172 | $sScriptAttr = $xGenerator->readyInlined() ? 'sJsInlineScript' : 'sJsReadyScript'; |
173 | 173 | $this->$sScriptAttr = trim($this->$sScriptAttr) . "\n\n" . trim($xGenerator->getReadyScript(), " \n"); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | $this->sJsScript = trim($this->sJsScript, " \n"); |
187 | 187 | $this->sJsReadyScript = trim($this->sJsReadyScript, " \n"); |
188 | 188 | $this->sJsInlineScript = trim($this->sJsInlineScript, " \n"); |
189 | - if(($this->sJsReadyScript)) |
|
189 | + if (($this->sJsReadyScript)) |
|
190 | 190 | { |
191 | 191 | $this->sJsReadyScript = $this->render('ready.js', ['sScript' => $this->sJsReadyScript . "\n"]); |
192 | 192 | } |
193 | - if(($this->sJsInlineScript)) |
|
193 | + if (($this->sJsInlineScript)) |
|
194 | 194 | { |
195 | 195 | $this->sJsInlineScript = $this->render('ready.js', ['sScript' => $this->sJsInlineScript . "\n"]); |
196 | 196 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | private function generateCodes() |
209 | 209 | { |
210 | - if($this->bGenerated) |
|
210 | + if ($this->bGenerated) |
|
211 | 211 | { |
212 | 212 | return; |
213 | 213 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $this->xAssetManager = $this->di->getAssetManager(); |
219 | 219 | $this->sJsOptions = $this->xAssetManager->getJsOptions(); |
220 | - foreach($this->aCodeGenerators as $sClassName) |
|
220 | + foreach ($this->aCodeGenerators as $sClassName) |
|
221 | 221 | { |
222 | 222 | $this->generatePluginCodes($sClassName); |
223 | 223 | } |
@@ -279,16 +279,16 @@ discard block |
||
279 | 279 | { |
280 | 280 | $this->generateCodes(); |
281 | 281 | $sScript = ''; |
282 | - if(($bIncludeCss)) |
|
282 | + if (($bIncludeCss)) |
|
283 | 283 | { |
284 | 284 | $sScript .= $this->getCss() . "\n"; |
285 | 285 | } |
286 | - if(($bIncludeJs)) |
|
286 | + if (($bIncludeJs)) |
|
287 | 287 | { |
288 | 288 | $sScript .= $this->getJs() . "\n"; |
289 | 289 | } |
290 | 290 | |
291 | - if(!($sUrl = $this->xAssetManager->createJsFiles($this))) |
|
291 | + if (!($sUrl = $this->xAssetManager->createJsFiles($this))) |
|
292 | 292 | { |
293 | 293 | return trim($sScript) . "\n\n" . $this->render('wrapper.js', |
294 | 294 | ['sScript' => trim($this->sJsScript) . "\n\n" . trim($this->sJsInlineScript)]); |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getOutput(): string |
88 | 88 | { |
89 | - return $this->getCommandCount() === 0 ? '{}' : |
|
90 | - json_encode(['jxnobj' => $this->aCommands]); |
|
89 | + return $this->getCommandCount() === 0 ? '{}' : json_encode(['jxnobj' => $this->aCommands]); |
|
91 | 90 | } |
92 | 91 | |
93 | 92 | /** |
@@ -127,7 +126,7 @@ discard block |
||
127 | 126 | */ |
128 | 127 | protected function str($xData): string |
129 | 128 | { |
130 | - return trim((string)$xData, " \t\n"); |
|
129 | + return trim((string) $xData, " \t\n"); |
|
131 | 130 | } |
132 | 131 | |
133 | 132 | /** |
@@ -186,7 +185,7 @@ discard block |
||
186 | 185 | public function toPsr(): PsrResponseInterface |
187 | 186 | { |
188 | 187 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
189 | - if($this->xRequest->getMethod() === 'GET') |
|
188 | + if ($this->xRequest->getMethod() === 'GET') |
|
190 | 189 | { |
191 | 190 | $xPsrResponse = $xPsrResponse |
192 | 191 | ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | public function appendCommands(array $aCommands, bool $bBefore = false) |
70 | 70 | { |
71 | 71 | $this->aCommands = ($bBefore) ? |
72 | - array_merge($aCommands, $this->aCommands) : |
|
73 | - array_merge($this->aCommands, $aCommands); |
|
72 | + array_merge($aCommands, $this->aCommands) : array_merge($this->aCommands, $aCommands); |
|
74 | 73 | } |
75 | 74 | |
76 | 75 | /** |
@@ -94,7 +93,7 @@ discard block |
||
94 | 93 | * |
95 | 94 | * @return ResponseInterface |
96 | 95 | */ |
97 | - public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface |
|
96 | + public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface |
|
98 | 97 | { |
99 | 98 | $this->aCommands[] = [ |
100 | 99 | 'cmd' => $this->str($sName), |
@@ -113,7 +112,7 @@ discard block |
||
113 | 112 | * @return ResponseInterface |
114 | 113 | */ |
115 | 114 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
116 | - array|JsonSerializable $aOptions): ResponseInterface |
|
115 | + array | JsonSerializable $aOptions): ResponseInterface |
|
117 | 116 | { |
118 | 117 | $this->aCommands[] = [ |
119 | 118 | 'cmd' => $this->str($sName), |
@@ -132,10 +131,10 @@ discard block |
||
132 | 131 | * |
133 | 132 | * @return ResponseInterface |
134 | 133 | */ |
135 | - protected function _addCommand(string $sName, array|JsonSerializable $aOptions, |
|
134 | + protected function _addCommand(string $sName, array | JsonSerializable $aOptions, |
|
136 | 135 | bool $bRemoveEmpty = false): ResponseInterface |
137 | 136 | { |
138 | - if($bRemoveEmpty) |
|
137 | + if ($bRemoveEmpty) |
|
139 | 138 | { |
140 | 139 | $aOptions = array_filter($aOptions, function($xOption) { |
141 | 140 | return $xOption === ''; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return ResponseInterface |
30 | 30 | */ |
31 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
31 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Convert to string |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $aArgs = func_get_args(); |
71 | 71 | array_shift($aArgs); |
72 | - return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
72 | + return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @return ResponseInterface |
27 | 27 | */ |
28 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
28 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Convert to string |
@@ -135,18 +135,18 @@ |
||
135 | 135 | { |
136 | 136 | $xPaginator = new Paginator($nCurrentPage, $nItemsPerPage, $nTotalItems); |
137 | 137 | $aPages = $xPaginator->pages(); |
138 | - if(count($aPages) === 0) |
|
138 | + if (count($aPages) === 0) |
|
139 | 139 | { |
140 | 140 | return; |
141 | 141 | } |
142 | 142 | $xStore = $this->_render($aPages); |
143 | - if(!$xStore) |
|
143 | + if (!$xStore) |
|
144 | 144 | { |
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Append the page number to the parameter list, if not yet given. |
149 | - if(!$xCall->hasPageNumber()) |
|
149 | + if (!$xCall->hasPageNumber()) |
|
150 | 150 | { |
151 | 151 | $xCall->addParameter(Parameter::PAGE_NUMBER, 0); |
152 | 152 | } |
@@ -167,30 +167,30 @@ |
||
167 | 167 | { |
168 | 168 | switch($this->getType()) |
169 | 169 | { |
170 | - case self::JS_CALL: |
|
171 | - return $this->getValue()->toArray(); |
|
172 | - case self::JS_VALUE: |
|
173 | - return [ |
|
174 | - '_type' => 'expr', |
|
175 | - 'calls' => [['_type' => 'attr', '_name' => $this->getValue()]], |
|
176 | - ]; |
|
177 | - case self::FORM_VALUES: |
|
178 | - return ['_type' => 'form', '_name' => $this->getValue()]; |
|
179 | - case self::INPUT_VALUE: |
|
180 | - return ['_type' => 'input', '_name' => $this->getValue()]; |
|
181 | - case self::CHECKED_VALUE: |
|
182 | - return ['_type' => 'checked', '_name' => $this->getValue()]; |
|
183 | - case self::ELEMENT_INNERHTML: |
|
184 | - return ['_type' => 'html', '_name' => $this->getValue()]; |
|
185 | - case self::PAGE_NUMBER: |
|
186 | - return ['_type' => 'page', '_name' => '']; |
|
187 | - case self::QUOTED_VALUE: |
|
188 | - case self::BOOL_VALUE: |
|
189 | - case self::NUMERIC_VALUE: |
|
190 | - case self::JSON_VALUE: |
|
191 | - default: |
|
192 | - // Return the value as is. |
|
193 | - return $this->getValue(); |
|
170 | + case self::JS_CALL: |
|
171 | + return $this->getValue()->toArray(); |
|
172 | + case self::JS_VALUE: |
|
173 | + return [ |
|
174 | + '_type' => 'expr', |
|
175 | + 'calls' => [['_type' => 'attr', '_name' => $this->getValue()]], |
|
176 | + ]; |
|
177 | + case self::FORM_VALUES: |
|
178 | + return ['_type' => 'form', '_name' => $this->getValue()]; |
|
179 | + case self::INPUT_VALUE: |
|
180 | + return ['_type' => 'input', '_name' => $this->getValue()]; |
|
181 | + case self::CHECKED_VALUE: |
|
182 | + return ['_type' => 'checked', '_name' => $this->getValue()]; |
|
183 | + case self::ELEMENT_INNERHTML: |
|
184 | + return ['_type' => 'html', '_name' => $this->getValue()]; |
|
185 | + case self::PAGE_NUMBER: |
|
186 | + return ['_type' => 'page', '_name' => '']; |
|
187 | + case self::QUOTED_VALUE: |
|
188 | + case self::BOOL_VALUE: |
|
189 | + case self::NUMERIC_VALUE: |
|
190 | + case self::JSON_VALUE: |
|
191 | + default: |
|
192 | + // Return the value as is. |
|
193 | + return $this->getValue(); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function make($xValue): ParameterInterface |
134 | 134 | { |
135 | - if($xValue instanceof ParameterInterface) |
|
135 | + if ($xValue instanceof ParameterInterface) |
|
136 | 136 | { |
137 | 137 | return $xValue; |
138 | 138 | } |
139 | - if(is_numeric($xValue)) |
|
139 | + if (is_numeric($xValue)) |
|
140 | 140 | { |
141 | 141 | return new Parameter(self::NUMERIC_VALUE, $xValue); |
142 | 142 | } |
143 | - if(is_string($xValue)) |
|
143 | + if (is_string($xValue)) |
|
144 | 144 | { |
145 | 145 | return new Parameter(self::QUOTED_VALUE, $xValue); |
146 | 146 | } |
147 | - if(is_bool($xValue)) |
|
147 | + if (is_bool($xValue)) |
|
148 | 148 | { |
149 | 149 | return new Parameter(self::BOOL_VALUE, $xValue); |
150 | 150 | } |
151 | - if($xValue instanceof JsCall) |
|
151 | + if ($xValue instanceof JsCall) |
|
152 | 152 | { |
153 | 153 | return new Parameter(self::JS_CALL, $xValue); |
154 | 154 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function jsonSerialize() |
167 | 167 | { |
168 | - switch($this->getType()) |
|
168 | + switch ($this->getType()) |
|
169 | 169 | { |
170 | 170 | case self::JS_CALL: |
171 | 171 | return $this->getValue()->toArray(); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function getNumericValueScript(): string |
288 | 288 | { |
289 | - return (string)$this->xValue; |
|
289 | + return (string) $this->xValue; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function getUnquotedValueScript(): string |
298 | 298 | { |
299 | - return (string)$this->xValue; |
|
299 | + return (string) $this->xValue; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function getPageNumberScript(): string |
320 | 320 | { |
321 | - return (string)$this->xValue; |
|
321 | + return (string) $this->xValue; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | public function getScript(): string |
330 | 330 | { |
331 | 331 | $sMethodName = 'get' . $this->sType . 'Script'; |
332 | - if(!method_exists($this, $sMethodName)) |
|
332 | + if (!method_exists($this, $sMethodName)) |
|
333 | 333 | { |
334 | 334 | return ''; |
335 | 335 | } |
@@ -304,18 +304,18 @@ discard block |
||
304 | 304 | public function toArray(): array |
305 | 305 | { |
306 | 306 | $aCall = parent::toArray(); |
307 | - if(($this->aConfirm)) |
|
307 | + if (($this->aConfirm)) |
|
308 | 308 | { |
309 | 309 | $aCall['confirm'] = [ |
310 | 310 | ...$this->aConfirm, |
311 | 311 | 'lib' => $this->xLibraryManager->getQuestionLibrary()->getName(), |
312 | 312 | ]; |
313 | 313 | } |
314 | - if(($this->aCondition)) |
|
314 | + if (($this->aCondition)) |
|
315 | 315 | { |
316 | 316 | $aCall['condition'] = $this->aCondition; |
317 | 317 | } |
318 | - if(($this->aMessage)) |
|
318 | + if (($this->aMessage)) |
|
319 | 319 | { |
320 | 320 | $aCall['else'] = [ |
321 | 321 | ...$this->aMessage, |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | */ |
333 | 333 | private function findPageNumber(): ?ParameterInterface |
334 | 334 | { |
335 | - foreach($this->aParameters as $xParameter) |
|
335 | + foreach ($this->aParameters as $xParameter) |
|
336 | 336 | { |
337 | - if($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
337 | + if ($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
338 | 338 | { |
339 | 339 | return $xParameter; |
340 | 340 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | { |
364 | 364 | /** @var Parameter */ |
365 | 365 | $xParameter = $this->findPageNumber(); |
366 | - if($xParameter !== null) |
|
366 | + if ($xParameter !== null) |
|
367 | 367 | { |
368 | 368 | $xParameter->setValue($nPageNumber); |
369 | 369 | } |