@@ -44,8 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
46 | 46 | { |
47 | - return empty($sNoScript) ? 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}' : |
|
48 | - 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}else{' . $sNoScript . ';}'; |
|
47 | + return empty($sNoScript) ? 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}' : 'if(confirm(' . $sQuestion . ')){' . $sYesScript . ';}else{' . $sNoScript . ';}'; |
|
49 | 48 | } |
50 | 49 | |
51 | 50 | /** |
@@ -53,7 +52,7 @@ discard block |
||
53 | 52 | */ |
54 | 53 | protected function alert(string $sMessage, string $sTitle, string $sType) |
55 | 54 | { |
56 | - if(!empty($sTitle)) |
|
55 | + if (!empty($sTitle)) |
|
57 | 56 | { |
58 | 57 | $sMessage = '<b>' . $sTitle . '</b><br/>' . $sMessage; |
59 | 58 | } |
@@ -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 === ''; |
@@ -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 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | private function checkDirectory(string $sDirectory): string |
81 | 81 | { |
82 | 82 | $sDirectory = rtrim(trim($sDirectory), '/\\'); |
83 | - if(!is_dir($sDirectory)) |
|
83 | + if (!is_dir($sDirectory)) |
|
84 | 84 | { |
85 | 85 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
86 | 86 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function checkOptions(string $sCallable, $xOptions): array |
95 | 95 | { |
96 | - if(is_string($xOptions)) |
|
96 | + if (is_string($xOptions)) |
|
97 | 97 | { |
98 | 98 | $xOptions = ['namespace' => $xOptions]; |
99 | 99 | } |
100 | - if(!is_array($xOptions)) |
|
100 | + if (!is_array($xOptions)) |
|
101 | 101 | { |
102 | 102 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
103 | 103 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $xOptions['directory'] = $this->checkDirectory($sCallable); |
106 | 106 | // Check the namespace |
107 | 107 | $sNamespace = $xOptions['namespace'] ?? ''; |
108 | - if(!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
108 | + if (!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
109 | 109 | { |
110 | 110 | $xOptions['namespace'] = ''; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Change the keys in $xOptions to have "\" as separator |
114 | 114 | $_aOptions = []; |
115 | - foreach($xOptions as $sName => $aOption) |
|
115 | + foreach ($xOptions as $sName => $aOption) |
|
116 | 116 | { |
117 | 117 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
118 | 118 | $_aOptions[$sName] = $aOption; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function register(string $sType, string $sCallable, array $aOptions): bool |
127 | 127 | { |
128 | - if(($aOptions['namespace'])) |
|
128 | + if (($aOptions['namespace'])) |
|
129 | 129 | { |
130 | 130 | $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions); |
131 | 131 | return true; |
@@ -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 | } |