@@ -20,14 +20,14 @@ |
||
20 | 20 | |
21 | 21 | trait ScriptTrait |
22 | 22 | { |
23 | - /** |
|
24 | - * Add a response command to the array of commands that will be sent to the browser |
|
25 | - * |
|
26 | - * @param string $sName The command name |
|
27 | - * @param array|JsonSerializable $aOptions The command options |
|
28 | - * |
|
29 | - * @return ResponseInterface |
|
30 | - */ |
|
23 | + /** |
|
24 | + * Add a response command to the array of commands that will be sent to the browser |
|
25 | + * |
|
26 | + * @param string $sName The command name |
|
27 | + * @param array|JsonSerializable $aOptions The command options |
|
28 | + * |
|
29 | + * @return ResponseInterface |
|
30 | + */ |
|
31 | 31 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
32 | 32 | |
33 | 33 | /** |
@@ -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 | * Response command that prompts user with [ok] [cancel] style message box |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $aArgs = func_get_args(); |
62 | 62 | array_shift($aArgs); |
63 | - return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
63 | + return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,7 +73,7 @@ |
||
73 | 73 | * @return ResponseInterface |
74 | 74 | */ |
75 | 75 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
76 | - array|JsonSerializable $aOptions): ResponseInterface; |
|
76 | + array | JsonSerializable $aOptions): ResponseInterface; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Convert this response to a PSR7 response object |
@@ -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' => 'jaxon.utils.string.toInt', |
152 | - 'params' => [[ '_type' => '_', '_name' => 'this' ]], |
|
152 | + 'params' => [['_type' => '_', '_name' => 'this']], |
|
153 | 153 | ]; |
154 | 154 | } |
155 | 155 | return [ |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public function selector(string $sPath = '', $xContext = null): DomSelector |
76 | 76 | { |
77 | 77 | $xSelector = new DomSelector($sPath, $xContext); |
78 | - if($this->bCommand && $this->response() !== null) |
|
78 | + if ($this->bCommand && $this->response() !== null) |
|
79 | 79 | { |
80 | 80 | $this->addCommand('jquery.call', ['selector' => $xSelector]); |
81 | 81 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private function initDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | $aBody = $xRequest->getParsedBody(); |
49 | 49 | $aParams = $xRequest->getQueryParams(); |
50 | 50 | $aData = is_array($aBody) ? |
51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
53 | 52 | $this->xDataBag = new DataBag($aData); |
54 | 53 | } |
55 | 54 | |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | { |
71 | 70 | // Todo: clean input data. |
72 | 71 | return is_string($xData) ? |
73 | - (json_decode($xData, true) ?: []) : |
|
74 | - (is_array($xData) ? $xData : []); |
|
72 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
75 | 73 | } |
76 | 74 | |
77 | 75 | /** |
@@ -89,7 +87,7 @@ discard block |
||
89 | 87 | public function writeCommand() |
90 | 88 | { |
91 | 89 | $this->initDataBag(); |
92 | - if($this->xDataBag->touched()) |
|
90 | + if ($this->xDataBag->touched()) |
|
93 | 91 | { |
94 | 92 | $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
95 | 93 | } |
@@ -331,15 +331,15 @@ discard block |
||
331 | 331 | public function toArray(): array |
332 | 332 | { |
333 | 333 | $aCall = parent::toArray(); |
334 | - if(($this->aConfirm)) |
|
334 | + if (($this->aConfirm)) |
|
335 | 335 | { |
336 | 336 | $aCall['confirm'] = $this->aConfirm; |
337 | 337 | } |
338 | - if(($this->aCondition)) |
|
338 | + if (($this->aCondition)) |
|
339 | 339 | { |
340 | 340 | $aCall['condition'] = $this->aCondition; |
341 | 341 | } |
342 | - if(($this->aMessage)) |
|
342 | + if (($this->aMessage)) |
|
343 | 343 | { |
344 | 344 | $aCall['else'] = $this->aMessage; |
345 | 345 | } |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | */ |
354 | 354 | private function findPageNumber(): ?ParameterInterface |
355 | 355 | { |
356 | - foreach($this->aParameters as $xParameter) |
|
356 | + foreach ($this->aParameters as $xParameter) |
|
357 | 357 | { |
358 | - if($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
358 | + if ($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
359 | 359 | { |
360 | 360 | return $xParameter; |
361 | 361 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | { |
385 | 385 | /** @var Parameter */ |
386 | 386 | $xParameter = $this->findPageNumber(); |
387 | - if($xParameter !== null) |
|
387 | + if ($xParameter !== null) |
|
388 | 388 | { |
389 | 389 | $xParameter->setValue($nPageNumber); |
390 | 390 | } |
@@ -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 | } |