Passed
Push — main ( 652a21...525366 )
by Thierry
03:56
created
jaxon-core/src/Di/Traits/PluginTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     public function registerPackage(string $sClassName, array $aUserOptions): void
194 194
     {
195 195
         // Register the user class, but only if the user didn't already.
196
-        if(!$this->h($sClassName))
196
+        if (!$this->h($sClassName))
197 197
         {
198 198
             $this->set($sClassName, fn() => $this->make($sClassName));
199 199
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         $this->set($sConfigKey, function($di) use($aUserOptions) {
204 204
             $xOptionsProvider = $aUserOptions['provider'] ?? null;
205 205
             // The user can provide a callable that returns the package options.
206
-            if(is_callable($xOptionsProvider))
206
+            if (is_callable($xOptionsProvider))
207 207
             {
208 208
                 $aUserOptions = $xOptionsProvider($aUserOptions);
209 209
             }
Please login to merge, or discard this patch.
jaxon-core/src/Response/Manager/ResponseManager.php 2 patches
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     private function getCommandArgs(array|JsonSerializable $aArgs, bool $bRemoveEmpty = false): array
188 188
     {
189
-        if(!$bRemoveEmpty)
189
+        if (!$bRemoveEmpty)
190 190
         {
191 191
             return $aArgs;
192 192
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             'name' => $this->str($sName),
212 212
             'args' => $this->getCommandArgs($aArgs, $bRemoveEmpty),
213 213
         ]);
214
-        if($this->bOnConfirm)
214
+        if ($this->bOnConfirm)
215 215
         {
216 216
             $this->aConfirmCommands[] = $xCommand;
217 217
         }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
     public function addConfirmCommand(string $sName, Closure $fConfirm,
241 241
         string $sQuestion, array $aArgs = []): self
242 242
     {
243
-        if($this->bOnConfirm)
243
+        if ($this->bOnConfirm)
244 244
         {
245 245
             throw new AppException($this->xTranslator->trans('errors.app.confirm.nested'));
246 246
         }
247 247
         $this->bOnConfirm = true;
248 248
         $fConfirm();
249 249
         $this->bOnConfirm = false;
250
-        if(($nCommandCount = count($this->aConfirmCommands)) > 0)
250
+        if (($nCommandCount = count($this->aConfirmCommands)) > 0)
251 251
         {
252 252
             $aCommand = $this->di->getDialogCommand()->confirm($this->str($sQuestion), $aArgs);
253 253
             $aCommand['count'] = $nCommandCount;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      */
355 355
     public function printDebug()
356 356
     {
357
-        foreach($this->aDebugMessages as $sMessage)
357
+        foreach ($this->aDebugMessages as $sMessage)
358 358
         {
359 359
             $this->addCommand('script.debug', ['message' => $this->str($sMessage)]);
360 360
         }
@@ -368,8 +368,7 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public function getContentType(): string
370 370
     {
371
-        return empty($this->sCharacterEncoding) ? $this->getResponse()->getContentType() :
372
-            $this->getResponse()->getContentType() . '; charset="' . $this->sCharacterEncoding . '"';
371
+        return empty($this->sCharacterEncoding) ? $this->getResponse()->getContentType() : $this->getResponse()->getContentType() . '; charset="' . $this->sCharacterEncoding . '"';
373 372
     }
374 373
 
375 374
     /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -214,8 +214,7 @@
 block discarded – undo
214 214
         if($this->bOnConfirm)
215 215
         {
216 216
             $this->aConfirmCommands[] = $xCommand;
217
-        }
218
-        else
217
+        } else
219 218
         {
220 219
             $this->aCommands[] = $xCommand;
221 220
         }
Please login to merge, or discard this patch.
jaxon-core/src/Response/Manager/Command.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
      */
67 67
     public function setOption(string $sName, string|array|JsonSerializable $xValue): Command
68 68
     {
69
-        if(isset($this->aCommand['options']))
69
+        if (isset($this->aCommand['options']))
70 70
         {
71 71
             $this->aCommand['options'][$this->str($sName)] = $xValue;
72 72
             return $this;
Please login to merge, or discard this patch.
jaxon-core/src/Response/AbstractResponse.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -91,15 +91,15 @@
 block discarded – undo
91 91
         return $this->xManager->getErrorMessage();
92 92
     }
93 93
 
94
-     /**
95
-     * Add a response command to the array of commands
96
-     *
97
-     * @param string $sName    The command name
98
-     * @param array|JsonSerializable $aArgs    The command arguments
99
-     * @param bool $bRemoveEmpty
100
-     *
101
-     * @return Command
102
-     */
94
+        /**
95
+         * Add a response command to the array of commands
96
+         *
97
+         * @param string $sName    The command name
98
+         * @param array|JsonSerializable $aArgs    The command arguments
99
+         * @param bool $bRemoveEmpty
100
+         *
101
+         * @return Command
102
+         */
103 103
     public function addCommand(string $sName, array|JsonSerializable $aArgs = [],
104 104
         bool $bRemoveEmpty = false): Command
105 105
     {
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Manager/PackageManager.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -218,8 +218,7 @@
 block discarded – undo
218 218
         {
219 219
             // A string is supposed to be the path to a config file.
220 220
             $aLibOptions = $this->xConfigManager->read($aLibOptions);
221
-        }
222
-        elseif(!is_array($aLibOptions))
221
+        } elseif(!is_array($aLibOptions))
223 222
         {
224 223
             // Otherwise, anything else than an array is not accepted.
225 224
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
     private function updateContainer(Config $xConfig): void
63 63
     {
64 64
         $aOptions = $xConfig->getOption('container.set', []);
65
-        foreach($aOptions as $xKey => $xValue)
65
+        foreach ($aOptions as $xKey => $xValue)
66 66
         {
67 67
             // The key is the class name. It must be a string.
68 68
             $this->di->set((string)$xKey, $xValue);
69 69
         }
70 70
         $aOptions = $xConfig->getOption('container.val', []);
71
-        foreach($aOptions as $xKey => $xValue)
71
+        foreach ($aOptions as $xKey => $xValue)
72 72
         {
73 73
             // The key is the class name. It must be a string.
74 74
             $this->di->val((string)$xKey, $xValue);
75 75
         }
76 76
         $aOptions = $xConfig->getOption('container.auto', []);
77
-        foreach($aOptions as $xValue)
77
+        foreach ($aOptions as $xValue)
78 78
         {
79 79
             // The key is the class name. It must be a string.
80 80
             $this->di->auto((string)$xValue);
81 81
         }
82 82
         $aOptions = $xConfig->getOption('container.alias', []);
83
-        foreach($aOptions as $xKey => $xValue)
83
+        foreach ($aOptions as $xKey => $xValue)
84 84
         {
85 85
             // The key is the class name. It must be a string.
86 86
             $this->di->alias((string)$xKey, (string)$xValue);
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function registerCallables(array $aOptions, string $sCallableType): void
100 100
     {
101
-        foreach($aOptions as $xKey => $xValue)
101
+        foreach ($aOptions as $xKey => $xValue)
102 102
         {
103
-            if(is_integer($xKey) && is_string($xValue))
103
+            if (is_integer($xKey) && is_string($xValue))
104 104
             {
105 105
                 // Register a function without options
106 106
                 $this->xPluginManager->registerCallable($sCallableType, $xValue);
107 107
                 continue;
108 108
             }
109 109
 
110
-            if(is_string($xKey) && (is_array($xValue) || is_string($xValue)))
110
+            if (is_string($xKey) && (is_array($xValue) || is_string($xValue)))
111 111
             {
112 112
                 // Register a function with options
113 113
                 $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function registerExceptionHandlers(Config $xConfig): void
126 126
     {
127
-        foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
127
+        foreach ($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
128 128
         {
129 129
             $this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : '');
130 130
         }
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
         // key of the array item, a string as the value of an entry without a key,
148 148
         // or set with the key $sOptionKey in an array entry without a key.
149 149
         $aCallables = [];
150
-        foreach($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
150
+        foreach ($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
151 151
         {
152
-            if(is_string($xKey))
152
+            if (is_string($xKey))
153 153
             {
154 154
                 $aCallables[$xKey] = $xValue;
155 155
                 continue;
156 156
             }
157
-            if(is_string($xValue))
157
+            if (is_string($xValue))
158 158
             {
159 159
                 $aCallables[] = $xValue;
160 160
                 continue;
161 161
             }
162 162
 
163
-            if(is_array($xValue) && isset($xValue[$sOptionKey]))
163
+            if (is_array($xValue) && isset($xValue[$sOptionKey]))
164 164
             {
165 165
                 $aCallables[$xValue[$sOptionKey]] = $xValue;
166 166
             }
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
     {
216 216
         // $this->aPackages contains packages config file paths.
217 217
         $aLibOptions = $sClassName::config();
218
-        if(is_string($aLibOptions))
218
+        if (is_string($aLibOptions))
219 219
         {
220 220
             // A string is supposed to be the path to a config file.
221 221
             $aLibOptions = $this->xConfigManager->read($aLibOptions);
222 222
         }
223
-        elseif(!is_array($aLibOptions))
223
+        elseif (!is_array($aLibOptions))
224 224
         {
225 225
             // Otherwise, anything else than an array is not accepted.
226 226
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     public function registerPackage(string $sClassName, array $aUserOptions = []): void
244 244
     {
245 245
         $sClassName = trim($sClassName, '\\ ');
246
-        if(!is_subclass_of($sClassName, AbstractPackage::class))
246
+        if (!is_subclass_of($sClassName, AbstractPackage::class))
247 247
         {
248 248
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
249 249
             throw new SetupException($sMessage);
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 
288 288
         // Register packages
289 289
         $aPackageConfig = $xAppConfig->getOption('packages', []);
290
-        foreach($aPackageConfig as $xKey => $xValue)
290
+        foreach ($aPackageConfig as $xKey => $xValue)
291 291
         {
292
-            if(is_integer($xKey) && is_string($xValue))
292
+            if (is_integer($xKey) && is_string($xValue))
293 293
             {
294 294
                 // Register a package without options
295 295
                 $sClassName = $xValue;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                 continue;
298 298
             }
299 299
 
300
-            if(is_string($xKey) && is_array($xValue))
300
+            if (is_string($xKey) && is_array($xValue))
301 301
             {
302 302
                 // Register a package with options
303 303
                 $sClassName = $xKey;
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Manager/PluginManager.php 1 patch
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int
101 101
     {
102 102
         // Any plugin must implement the PluginInterface interface.
103
-        if(!in_array(PluginInterface::class, $aInterfaces))
103
+        if (!in_array(PluginInterface::class, $aInterfaces))
104 104
         {
105 105
             $sMessage = $this->xTranslator->trans('errors.register.invalid', [
106 106
                 'name' => $sClassName,
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         // Response plugin.
112
-        if(in_array(ResponsePluginInterface::class, $aInterfaces))
112
+        if (in_array(ResponsePluginInterface::class, $aInterfaces))
113 113
         {
114 114
             $this->aResponsePlugins[$sPluginName] = $sClassName;
115 115
             return 1;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 
118 118
         // Request plugin.
119 119
         $nCount = 0;
120
-        if(in_array(CallableRegistryInterface::class, $aInterfaces))
120
+        if (in_array(CallableRegistryInterface::class, $aInterfaces))
121 121
         {
122 122
             $this->aRegistryPlugins[$sPluginName] = $sClassName;
123 123
             $nCount++;
124 124
         }
125
-        if(in_array(RequestHandlerInterface::class, $aInterfaces))
125
+        if (in_array(RequestHandlerInterface::class, $aInterfaces))
126 126
         {
127 127
             $this->aRequestHandlers[$sPluginName] = $sClassName;
128 128
             $nCount++;
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         $nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces);
152 152
 
153 153
         // Any plugin can implement the CodeGeneratorInterface interface.
154
-        if(in_array(CodeGeneratorInterface::class, $aInterfaces))
154
+        if (in_array(CodeGeneratorInterface::class, $aInterfaces))
155 155
         {
156 156
             $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority);
157 157
             $nCount++;
158 158
         }
159 159
         // The class is not a valid plugin.
160
-        if($nCount === 0)
160
+        if ($nCount === 0)
161 161
         {
162 162
             $sMessage = $this->xTranslator->trans('errors.register.invalid', [
163 163
                 'name' => $sClassName,
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         }
167 167
 
168 168
         // Register the plugin in the DI container, if necessary
169
-        if(!$this->di->has($sClassName))
169
+        if (!$this->di->has($sClassName))
170 170
         {
171 171
             $this->di->auto($sClassName);
172 172
         }
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function getResponsePlugin(string $sName): ?ResponsePluginInterface
184 184
     {
185
-        return $this->di->h($sName) ? $this->di->g($sName) :
186
-            (!isset($this->aResponsePlugins[$sName]) ? null :
185
+        return $this->di->h($sName) ? $this->di->g($sName) : (!isset($this->aResponsePlugins[$sName]) ? null :
187 186
             $this->di->g($this->aResponsePlugins[$sName]));
188 187
     }
189 188
 
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
      */
202 201
     public function registerCallable(string $sType, string $sCallable, $xOptions = []): void
203 202
     {
204
-        if(isset($this->aRegistryPlugins[$sType]) &&
203
+        if (isset($this->aRegistryPlugins[$sType]) &&
205 204
             ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType])))
206 205
         {
207 206
             $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions));
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Psr/PsrPlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     public function ajaxResponse(): ResponseInterface
64 64
     {
65 65
         $xPsrResponse = $this->xPsr17Factory->createResponse(200);
66
-        if($this->xRequest->getMethod() === 'GET')
66
+        if ($this->xRequest->getMethod() === 'GET')
67 67
         {
68 68
             $xPsrResponse = $xPsrResponse
69 69
                 ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -23,56 +23,56 @@
 block discarded – undo
23 23
 
24 24
 class PsrPlugin extends AbstractResponsePlugin
25 25
 {
26
-    /**
26
+/**
27 27
      * @const The plugin name
28 28
      */
29
-    public const NAME = 'psr';
29
+public const NAME = 'psr';
30 30
 
31
-    /**
31
+/**
32 32
      * The class constructor
33 33
      *
34 34
      * @param Psr17Factory $xPsr17Factory
35 35
      * @param RequestInterface $xRequest
36 36
      */
37
-    public function __construct(private Psr17Factory $xPsr17Factory,
38
-        private RequestInterface $xRequest)
39
-    {}
37
+public function __construct(private Psr17Factory $xPsr17Factory,
38
+private RequestInterface $xRequest)
39
+{}
40 40
 
41
-    /**
41
+/**
42 42
      * @inheritDoc
43 43
      */
44
-    public function getName(): string
45
-    {
46
-        return self::NAME;
47
-    }
44
+public function getName(): string
45
+{
46
+return self::NAME;
47
+}
48 48
 
49
-    /**
49
+/**
50 50
      * @inheritDoc
51 51
      */
52
-    public function getHash(): string
53
-    {
54
-        // Use the version number as hash
55
-        return '5.0.0';
56
-    }
52
+public function getHash(): string
53
+{
54
+// Use the version number as hash
55
+return '5.0.0';
56
+}
57 57
 
58
-    /**
58
+/**
59 59
      * Convert an ajax response to a PSR7 response object
60 60
      *
61 61
      * @return ResponseInterface
62 62
      */
63
-    public function ajaxResponse(): ResponseInterface
64
-    {
65
-        $xPsrResponse = $this->xPsr17Factory->createResponse(200);
66
-        if($this->xRequest->getMethod() === 'GET')
67
-        {
68
-            $xPsrResponse = $xPsrResponse
69
-                ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
70
-                ->withHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT')
71
-                ->withHeader('Cache-Control', 'no-cache, must-revalidate')
72
-                ->withHeader('Pragma', 'no-cache');
73
-        }
74
-        return $xPsrResponse
75
-            ->withHeader('content-type', $this->response()->getContentType())
76
-            ->withBody(Stream::create($this->response()->getOutput()));
77
-    }
63
+public function ajaxResponse(): ResponseInterface
64
+{
65
+$xPsrResponse = $this->xPsr17Factory->createResponse(200);
66
+if($this->xRequest->getMethod() === 'GET')
67
+{
68
+$xPsrResponse = $xPsrResponse
69
+    ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
70
+    ->withHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT')
71
+    ->withHeader('Cache-Control', 'no-cache, must-revalidate')
72
+    ->withHeader('Pragma', 'no-cache');
73
+}
74
+return $xPsrResponse
75
+->withHeader('content-type', $this->response()->getContentType())
76
+->withBody(Stream::create($this->response()->getOutput()));
77
+}
78 78
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/DataBag/DataBagPlugin.php 2 patches
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     private function initDataBag(): void
36 36
     {
37
-        if($this->xDataBag !== null)
37
+        if ($this->xDataBag !== null)
38 38
         {
39 39
             return;
40 40
         }
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
         $aBody = $xRequest->getParsedBody();
45 45
         $aParams = $xRequest->getQueryParams();
46 46
         $aData = is_array($aBody) ?
47
-            $this->readData($aBody['jxnbags'] ?? []) :
48
-            $this->readData($aParams['jxnbags'] ?? []);
47
+            $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []);
49 48
         $this->xDataBag = new DataBag($this, $aData);
50 49
     }
51 50
 
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
         // Todo: clean input data.
68 67
         // Todo: verify the checksums.
69 68
         return is_string($xData) ?
70
-            (json_decode($xData, true) ?: []) :
71
-            (is_array($xData) ? $xData : []);
69
+            (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []);
72 70
     }
73 71
 
74 72
     /**
@@ -86,7 +84,7 @@  discard block
 block discarded – undo
86 84
     public function writeCommand(): void
87 85
     {
88 86
         $this->initDataBag();
89
-        if($this->xDataBag->touched())
87
+        if ($this->xDataBag->touched())
90 88
         {
91 89
             // Todo: calculate the checksums.
92 90
             $this->addCommand('databag.set', ['values' => $this->xDataBag]);
Please login to merge, or discard this patch.
Switch Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -13,94 +13,94 @@
 block discarded – undo
13 13
 
14 14
 class DataBagPlugin extends AbstractResponsePlugin
15 15
 {
16
-    /**
16
+/**
17 17
      * @const The plugin name
18 18
      */
19
-    public const NAME = 'bags';
19
+public const NAME = 'bags';
20 20
 
21
-    /**
21
+/**
22 22
      * @var DataBag
23 23
      */
24
-    protected $xDataBag = null;
24
+protected $xDataBag = null;
25 25
 
26
-    /**
26
+/**
27 27
      * The constructor
28 28
      */
29
-    public function __construct(protected Container $di)
30
-    {}
29
+public function __construct(protected Container $di)
30
+{}
31 31
 
32
-    /**
32
+/**
33 33
      * @return void
34 34
      */
35
-    private function initDataBag(): void
36
-    {
37
-        if($this->xDataBag !== null)
38
-        {
39
-            return;
40
-        }
35
+private function initDataBag(): void
36
+{
37
+if($this->xDataBag !== null)
38
+{
39
+return;
40
+}
41 41
 
42
-        // Get the databag contents from the HTTP request parameters.
43
-        $xRequest = $this->di->getRequest();
44
-        $aBody = $xRequest->getParsedBody();
45
-        $aParams = $xRequest->getQueryParams();
46
-        $aData = is_array($aBody) ?
47
-            $this->readData($aBody['jxnbags'] ?? []) :
48
-            $this->readData($aParams['jxnbags'] ?? []);
49
-        $this->xDataBag = new DataBag($this, $aData);
50
-    }
42
+// Get the databag contents from the HTTP request parameters.
43
+$xRequest = $this->di->getRequest();
44
+$aBody = $xRequest->getParsedBody();
45
+$aParams = $xRequest->getQueryParams();
46
+$aData = is_array($aBody) ?
47
+$this->readData($aBody['jxnbags'] ?? []) :
48
+$this->readData($aParams['jxnbags'] ?? []);
49
+$this->xDataBag = new DataBag($this, $aData);
50
+}
51 51
 
52
-    /**
52
+/**
53 53
      * @inheritDoc
54 54
      */
55
-    public function getName(): string
56
-    {
57
-        return self::NAME;
58
-    }
55
+public function getName(): string
56
+{
57
+return self::NAME;
58
+}
59 59
 
60
-    /**
60
+/**
61 61
      * @param mixed $xData
62 62
      *
63 63
      * @return array
64 64
      */
65
-    private function readData($xData): array
66
-    {
67
-        // Todo: clean input data.
68
-        // Todo: verify the checksums.
69
-        return is_string($xData) ?
70
-            (json_decode($xData, true) ?: []) :
71
-            (is_array($xData) ? $xData : []);
72
-    }
65
+private function readData($xData): array
66
+{
67
+// Todo: clean input data.
68
+// Todo: verify the checksums.
69
+return is_string($xData) ?
70
+(json_decode($xData, true) ?: []) :
71
+(is_array($xData) ? $xData : []);
72
+}
73 73
 
74
-    /**
74
+/**
75 75
      * @inheritDoc
76 76
      */
77
-    public function getHash(): string
78
-    {
79
-        // Use the version number as hash
80
-        return '4.0.0';
81
-    }
77
+public function getHash(): string
78
+{
79
+// Use the version number as hash
80
+return '4.0.0';
81
+}
82 82
 
83
-    /**
83
+/**
84 84
      * @return void
85 85
      */
86
-    public function writeCommand(): void
87
-    {
88
-        $this->initDataBag();
89
-        if($this->xDataBag->touched())
90
-        {
91
-            // Todo: calculate the checksums.
92
-            $this->addCommand('databag.set', ['values' => $this->xDataBag]);
93
-        }
94
-    }
86
+public function writeCommand(): void
87
+{
88
+$this->initDataBag();
89
+if($this->xDataBag->touched())
90
+{
91
+// Todo: calculate the checksums.
92
+$this->addCommand('databag.set', ['values' => $this->xDataBag]);
93
+}
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * @param string $sName
98 98
      *
99 99
      * @return DataBagContext
100 100
      */
101
-    public function bag(string $sName): DataBagContext
102
-    {
103
-        $this->initDataBag();
104
-        return new DataBagContext($this->xDataBag, $sName);
105
-    }
101
+public function bag(string $sName): DataBagContext
102
+{
103
+$this->initDataBag();
104
+return new DataBagContext($this->xDataBag, $sName);
105
+}
106 106
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/ConfigScriptGenerator.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
52 52
     public function getScript(): string
53 53
     {
54 54
         // It is important to call $this->xParameterReader->uri() only if necessary.
55
-        $sUri = $this->xConfigManager->getOption('core.request.uri') ?:
56
-            $this->xParameterReader->uri();
55
+        $sUri = $this->xConfigManager->getOption('core.request.uri') ?: $this->xParameterReader->uri();
57 56
         $aOptions = [
58 57
             'sResponseType'      => 'JSON',
59 58
             'sVersion'           => $this->option('core.version'),
Please login to merge, or discard this patch.
Switch Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,53 +22,53 @@
 block discarded – undo
22 22
 
23 23
 class ConfigScriptGenerator extends AbstractCodeGenerator
24 24
 {
25
-    /**
25
+/**
26 26
      * The constructor
27 27
      *
28 28
      * @param ParameterReader $xParameterReader
29 29
      * @param TemplateEngine $xTemplateEngine
30 30
      * @param ConfigManager $xConfigManager
31 31
      */
32
-    public function __construct(private ParameterReader $xParameterReader,
33
-        private TemplateEngine $xTemplateEngine, private ConfigManager $xConfigManager)
34
-    {}
32
+public function __construct(private ParameterReader $xParameterReader,
33
+private TemplateEngine $xTemplateEngine, private ConfigManager $xConfigManager)
34
+{}
35 35
 
36
-    /**
36
+/**
37 37
      * Get the value of a config option
38 38
      *
39 39
      * @param string $sName The option name
40 40
      *
41 41
      * @return mixed
42 42
      */
43
-    private function option(string $sName): mixed
44
-    {
45
-        return $this->xConfigManager->getOption($sName);
46
-    }
43
+private function option(string $sName): mixed
44
+{
45
+return $this->xConfigManager->getOption($sName);
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * @inheritDoc
50 50
      * @throws UriException
51 51
      */
52
-    public function getScript(): string
53
-    {
54
-        // It is important to call $this->xParameterReader->uri() only if necessary.
55
-        $sUri = $this->xConfigManager->getOption('core.request.uri') ?:
56
-            $this->xParameterReader->uri();
57
-        $aOptions = [
58
-            'sResponseType'      => 'JSON',
59
-            'sVersion'           => $this->option('core.version'),
60
-            'sLanguage'          => $this->option('core.language'),
61
-            'sRequestURI'        => $sUri,
62
-            'sDefaultMode'       => $this->option('core.request.mode'),
63
-            'sDefaultMethod'     => $this->option('core.request.method'),
64
-            'sCsrfMetaName'      => $this->option('core.request.csrf_meta'),
65
-            'bDebug'             => $this->option('core.debug.on'),
66
-            'bVerboseDebug'      => $this->option('core.debug.verbose'),
67
-            'sDebugOutputID'     => $this->option('core.debug.output_id'),
68
-            'nResponseQueueSize' => $this->option('js.lib.queue_size'),
69
-            'sStatusMessages'    => $this->option('js.lib.show_status') ? 'true' : 'false',
70
-            'sWaitCursor'        => $this->option('js.lib.show_cursor') ? 'true' : 'false',
71
-        ];
72
-        return $this->xTemplateEngine->render('jaxon::plugins/config.js', $aOptions);
73
-    }
52
+public function getScript(): string
53
+{
54
+// It is important to call $this->xParameterReader->uri() only if necessary.
55
+$sUri = $this->xConfigManager->getOption('core.request.uri') ?:
56
+$this->xParameterReader->uri();
57
+$aOptions = [
58
+'sResponseType'      => 'JSON',
59
+'sVersion'           => $this->option('core.version'),
60
+'sLanguage'          => $this->option('core.language'),
61
+'sRequestURI'        => $sUri,
62
+'sDefaultMode'       => $this->option('core.request.mode'),
63
+'sDefaultMethod'     => $this->option('core.request.method'),
64
+'sCsrfMetaName'      => $this->option('core.request.csrf_meta'),
65
+'bDebug'             => $this->option('core.debug.on'),
66
+'bVerboseDebug'      => $this->option('core.debug.verbose'),
67
+'sDebugOutputID'     => $this->option('core.debug.output_id'),
68
+'nResponseQueueSize' => $this->option('js.lib.queue_size'),
69
+'sStatusMessages'    => $this->option('js.lib.show_status') ? 'true' : 'false',
70
+'sWaitCursor'        => $this->option('js.lib.show_cursor') ? 'true' : 'false',
71
+];
72
+return $this->xTemplateEngine->render('jaxon::plugins/config.js', $aOptions);
73
+}
74 74
 }
Please login to merge, or discard this patch.