@@ -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 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function str($xData): string |
| 128 | 128 | { |
| 129 | - return trim((string)$xData, " \t\n"); |
|
| 129 | + return trim((string) $xData, " \t\n"); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | public function toPsr(): PsrResponseInterface |
| 186 | 186 | { |
| 187 | 187 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
| 188 | - if($this->xRequest->getMethod() === 'GET') |
|
| 188 | + if ($this->xRequest->getMethod() === 'GET') |
|
| 189 | 189 | { |
| 190 | 190 | $xPsrResponse = $xPsrResponse |
| 191 | 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 | 'name' => $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 | 'name' => $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 === ''; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $sName = $this->sPath ?? 'this'; |
| 170 | 170 | $aCall = ['_type' => 'select', '_name' => $sName]; |
| 171 | - if(($this->xContext)) |
|
| 171 | + if (($this->xContext)) |
|
| 172 | 172 | { |
| 173 | 173 | $aCall['context'] = $this->xContext; |
| 174 | 174 | } |
@@ -181,16 +181,16 @@ discard block |
||
| 181 | 181 | public function toArray(): array |
| 182 | 182 | { |
| 183 | 183 | $aCalls = [$this->selector()]; |
| 184 | - foreach($this->aCalls as $xCall) |
|
| 184 | + foreach ($this->aCalls as $xCall) |
|
| 185 | 185 | { |
| 186 | 186 | $aCalls[] = $xCall->jsonSerialize(); |
| 187 | 187 | } |
| 188 | - if($this->bToInt) |
|
| 188 | + if ($this->bToInt) |
|
| 189 | 189 | { |
| 190 | 190 | $aCalls[] = [ |
| 191 | 191 | '_type' => 'func', |
| 192 | 192 | '_name' => 'toInt', |
| 193 | - 'args' => [[ '_type' => '_', '_name' => 'this' ]], |
|
| 193 | + 'args' => [['_type' => '_', '_name' => 'this']], |
|
| 194 | 194 | ]; |
| 195 | 195 | } |
| 196 | 196 | return ['_type' => 'expr', 'calls' => $aCalls]; |
@@ -302,15 +302,15 @@ discard block |
||
| 302 | 302 | public function toArray(): array |
| 303 | 303 | { |
| 304 | 304 | $aCall = parent::toArray(); |
| 305 | - if(($this->aConfirm)) |
|
| 305 | + if (($this->aConfirm)) |
|
| 306 | 306 | { |
| 307 | 307 | $aCall['question'] = $this->aConfirm; |
| 308 | 308 | } |
| 309 | - if(($this->aCondition)) |
|
| 309 | + if (($this->aCondition)) |
|
| 310 | 310 | { |
| 311 | 311 | $aCall['condition'] = $this->aCondition; |
| 312 | 312 | } |
| 313 | - if(($this->aMessage)) |
|
| 313 | + if (($this->aMessage)) |
|
| 314 | 314 | { |
| 315 | 315 | $aCall['message'] = $this->aMessage; |
| 316 | 316 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | private function findPageNumber(): ?ParameterInterface |
| 326 | 326 | { |
| 327 | - foreach($this->aParameters as $xParameter) |
|
| 327 | + foreach ($this->aParameters as $xParameter) |
|
| 328 | 328 | { |
| 329 | - if($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
| 329 | + if ($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
| 330 | 330 | { |
| 331 | 331 | return $xParameter; |
| 332 | 332 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | { |
| 356 | 356 | /** @var Parameter */ |
| 357 | 357 | $xParameter = $this->findPageNumber(); |
| 358 | - if($xParameter !== null) |
|
| 358 | + if ($xParameter !== null) |
|
| 359 | 359 | { |
| 360 | 360 | $xParameter->setValue($nPageNumber); |
| 361 | 361 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function addParameters(array $aParameters): JsCall |
| 125 | 125 | { |
| 126 | - foreach($aParameters as $xParameter) |
|
| 126 | + foreach ($aParameters as $xParameter) |
|
| 127 | 127 | { |
| 128 | 128 | $this->pushParameter(Parameter::make($xParameter)); |
| 129 | 129 | } |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | return $xParam->jsonSerialize(); |
| 145 | 145 | }, $this->aParameters), |
| 146 | 146 | ]]; |
| 147 | - if($this->bToInt) |
|
| 147 | + if ($this->bToInt) |
|
| 148 | 148 | { |
| 149 | 149 | $aCalls[] = [ |
| 150 | 150 | '_type' => 'func', |
| 151 | 151 | '_name' => 'toInt', |
| 152 | - 'args' => [[ '_type' => '_', '_name' => 'this' ]], |
|
| 152 | + 'args' => [['_type' => '_', '_name' => 'this']], |
|
| 153 | 153 | ]; |
| 154 | 154 | } |
| 155 | 155 | return ['_type' => 'expr', 'calls' => $aCalls]; |