Passed
Push — main ( 273db0...683317 )
by Thierry
03:54
created
jaxon-core/src/Di/ComponentContainer.php 4 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,8 +189,7 @@
 block discarded – undo
189 189
             {
190 190
                 $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
191 191
             }
192
-        }
193
-        catch(ReflectionException $e)
192
+        } catch(ReflectionException $e)
194 193
         {
195 194
             throw new SetupException($this->cn()->g(Translator::class)
196 195
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
      */
142 142
     public function val(string $sKey, $xValue): void
143 143
     {
144
-       $this->xContainer->offsetSet($sKey, $xValue);
144
+        $this->xContainer->offsetSet($sKey, $xValue);
145 145
     }
146 146
 
147 147
     /**
Please login to merge, or discard this patch.
Switch Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -40,85 +40,85 @@  discard block
 block discarded – undo
40 40
 
41 41
 class ComponentContainer
42 42
 {
43
-    use Traits\DiAutoTrait;
44
-    use Traits\ComponentTrait;
43
+use Traits\DiAutoTrait;
44
+use Traits\ComponentTrait;
45 45
 
46
-    /**
46
+/**
47 47
      * The Dependency Injection Container for registered classes
48 48
      *
49 49
      * @var PimpleContainer
50 50
      */
51
-    private $xContainer;
51
+private $xContainer;
52 52
 
53
-    /**
53
+/**
54 54
      * This will be set only when getting the object targetted by the ajax request.
55 55
      *
56 56
      * @var Target|null
57 57
      */
58
-    private $xTarget = null;
58
+private $xTarget = null;
59 59
 
60
-    /**
60
+/**
61 61
      * The class constructor
62 62
      *
63 63
      * @param Container $di
64 64
      */
65
-    public function __construct(private Container $di)
66
-    {
67
-        $this->xContainer = new PimpleContainer();
68
-        $this->val(ComponentContainer::class, $this);
69
-
70
-        // Register the call factory for registered functions
71
-        $this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
72
-            new JxnCall($this->di->g(ConfigManager::class)
73
-                ->getOption('core.prefix.function', '')));
74
-
75
-        // Register the pagination component, but do not export to js.
76
-        $this->saveComponent(Pagination::class, [
77
-            'excluded' => true,
78
-            'separator' => '.',
79
-            // The namespace has the same name as the Component class.
80
-            'namespace' => Component::class,
81
-        ]);
82
-
83
-        // Register the logger component, and export to js.
84
-        $this->di->callback()->boot(function() {
85
-            if($this->di->config()->loggingEnabled())
86
-            {
87
-                $this->saveComponent(LoggerComponent::class, [
88
-                    'separator' => '.',
89
-                    // The namespace has the same name as the Component class.
90
-                    'namespace' => Component::class,
91
-                ]);
92
-            }
93
-        });
94
-
95
-        $this->setComponentPublicMethods('node', NodeComponent::class, ['item', 'html']);
96
-        $this->setComponentPublicMethods('func', FuncComponent::class, ['paginator']);
97
-    }
65
+public function __construct(private Container $di)
66
+{
67
+$this->xContainer = new PimpleContainer();
68
+$this->val(ComponentContainer::class, $this);
69
+
70
+// Register the call factory for registered functions
71
+$this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
72
+new JxnCall($this->di->g(ConfigManager::class)
73
+    ->getOption('core.prefix.function', '')));
74
+
75
+// Register the pagination component, but do not export to js.
76
+$this->saveComponent(Pagination::class, [
77
+'excluded' => true,
78
+'separator' => '.',
79
+// The namespace has the same name as the Component class.
80
+'namespace' => Component::class,
81
+]);
82
+
83
+// Register the logger component, and export to js.
84
+$this->di->callback()->boot(function() {
85
+if($this->di->config()->loggingEnabled())
86
+{
87
+    $this->saveComponent(LoggerComponent::class, [
88
+        'separator' => '.',
89
+        // The namespace has the same name as the Component class.
90
+        'namespace' => Component::class,
91
+    ]);
92
+}
93
+});
94
+
95
+$this->setComponentPublicMethods('node', NodeComponent::class, ['item', 'html']);
96
+$this->setComponentPublicMethods('func', FuncComponent::class, ['paginator']);
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * The container for parameters
101 101
      *
102 102
      * @return Container
103 103
      */
104
-    protected function cn(): Container
105
-    {
106
-        return $this->di;
107
-    }
104
+protected function cn(): Container
105
+{
106
+return $this->di;
107
+}
108 108
 
109
-    /**
109
+/**
110 110
      * Check if a class is defined in the container
111 111
      *
112 112
      * @param class-string $sClass    The full class name
113 113
      *
114 114
      * @return bool
115 115
      */
116
-    public function has(string $sClass): bool
117
-    {
118
-        return $this->xContainer->offsetExists($sClass);
119
-    }
116
+public function has(string $sClass): bool
117
+{
118
+return $this->xContainer->offsetExists($sClass);
119
+}
120 120
 
121
-    /**
121
+/**
122 122
      * Save a closure in the container
123 123
      *
124 124
      * @param class-string $sClass    The full class name
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
      *
127 127
      * @return void
128 128
      */
129
-    public function set(string $sClass, Closure $xClosure): void
130
-    {
131
-        $this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
132
-    }
129
+public function set(string $sClass, Closure $xClosure): void
130
+{
131
+$this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
132
+}
133 133
 
134
-    /**
134
+/**
135 135
      * Save a value in the container
136 136
      *
137 137
      * @param string|class-string $sKey    The key
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return void
141 141
      */
142
-    public function val(string $sKey, $xValue): void
143
-    {
144
-       $this->xContainer->offsetSet($sKey, $xValue);
145
-    }
142
+public function val(string $sKey, $xValue): void
143
+{
144
+$this->xContainer->offsetSet($sKey, $xValue);
145
+}
146 146
 
147
-    /**
147
+/**
148 148
      * Get a class instance
149 149
      *
150 150
      * @template T
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return T
154 154
      */
155
-    public function get(string $sClass): mixed
156
-    {
157
-        return $this->xContainer->offsetGet($sClass);
158
-    }
155
+public function get(string $sClass): mixed
156
+{
157
+return $this->xContainer->offsetGet($sClass);
158
+}
159 159
 
160
-    /**
160
+/**
161 161
      * Get a component when one of its method needs to be called
162 162
      *
163 163
      * @template T
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
      *
167 167
      * @return T|null
168 168
      */
169
-    public function getTargetComponent(string $sClassName, Target $xTarget): mixed
170
-    {
171
-        // Set the target only when getting the object targetted by the ajax request.
172
-        $this->xTarget = $xTarget;
173
-        $xComponent = $this->get($sClassName);
174
-        $this->xTarget = null;
169
+public function getTargetComponent(string $sClassName, Target $xTarget): mixed
170
+{
171
+// Set the target only when getting the object targetted by the ajax request.
172
+$this->xTarget = $xTarget;
173
+$xComponent = $this->get($sClassName);
174
+$this->xTarget = null;
175 175
 
176
-        return $xComponent;
177
-    }
176
+return $xComponent;
177
+}
178 178
 
179
-    /**
179
+/**
180 180
      * Register a component and its options
181 181
      *
182 182
      * @param class-string $sClassName    The class name
@@ -184,40 +184,40 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @return void
186 186
      */
187
-    public function saveComponent(string $sClassName, array $aOptions): void
188
-    {
189
-        try
190
-        {
191
-            // Make sure the registered class exists
192
-            if(isset($aOptions['include']))
193
-            {
194
-                require_once $aOptions['include'];
195
-            }
196
-            $xReflectionClass = new ReflectionClass($sClassName);
197
-            // Check if the class is registrable
198
-            if(!$xReflectionClass->isInstantiable())
199
-            {
200
-                return;
201
-            }
202
-
203
-            $this->_saveClassOptions($sClassName, $aOptions);
204
-
205
-            $sClassKey = $this->getReflectionClassKey($sClassName);
206
-            $this->val($sClassKey, $xReflectionClass);
207
-            // Register the user class, but only if the user didn't already.
208
-            if(!$this->has($sClassName))
209
-            {
210
-                $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
211
-            }
212
-        }
213
-        catch(ReflectionException $e)
214
-        {
215
-            throw new SetupException($this->cn()->g(Translator::class)
216
-                ->trans('errors.class.invalid', ['name' => $sClassName]));
217
-        }
218
-    }
187
+public function saveComponent(string $sClassName, array $aOptions): void
188
+{
189
+try
190
+{
191
+// Make sure the registered class exists
192
+if(isset($aOptions['include']))
193
+{
194
+    require_once $aOptions['include'];
195
+}
196
+$xReflectionClass = new ReflectionClass($sClassName);
197
+// Check if the class is registrable
198
+if(!$xReflectionClass->isInstantiable())
199
+{
200
+    return;
201
+}
219 202
 
220
-    /**
203
+$this->_saveClassOptions($sClassName, $aOptions);
204
+
205
+$sClassKey = $this->getReflectionClassKey($sClassName);
206
+$this->val($sClassKey, $xReflectionClass);
207
+// Register the user class, but only if the user didn't already.
208
+if(!$this->has($sClassName))
209
+{
210
+    $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
211
+}
212
+}
213
+catch(ReflectionException $e)
214
+{
215
+throw new SetupException($this->cn()->g(Translator::class)
216
+    ->trans('errors.class.invalid', ['name' => $sClassName]));
217
+}
218
+}
219
+
220
+/**
221 221
      * Register a component
222 222
      *
223 223
      * @param string $sComponentId The component name
@@ -225,74 +225,74 @@  discard block
 block discarded – undo
225 225
      * @return string
226 226
      * @throws SetupException
227 227
      */
228
-    private function _registerComponent(string $sComponentId): string
229
-    {
230
-        // Replace all separators ('.' or '_') with antislashes, and trim the class name.
231
-        $sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
232
-
233
-        $sComponentObject = $this->getCallableObjectKey($sClassName);
234
-        // Prevent duplication. It's important not to use the class name here.
235
-        if($this->has($sComponentObject))
236
-        {
237
-            return $sClassName;
238
-        }
239
-
240
-        // Register the helper class
241
-        $this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
242
-            $xFactory = $this->di->getCallFactory();
243
-            return new ComponentHelper($this, $xFactory->rq($sClassName),
244
-                $xFactory, $this->di->getViewRenderer(),
245
-                $this->di->getLogger(), $this->di->getSessionManager(),
246
-                $this->di->getStash(), $this->di->getUploadHandler());
247
-        });
248
-
249
-        $this->discoverComponent($sClassName);
250
-
251
-        // Register the callable object
252
-        $this->set($sComponentObject, function() use($sComponentId, $sClassName) {
253
-            $aOptions = $this->_getClassOptions($sComponentId);
254
-            $xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
255
-            $xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
256
-            return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
257
-        });
258
-
259
-        // Initialize the user class instance
260
-        $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
261
-            if($xClassInstance instanceof AbstractComponent)
262
-            {
263
-                $xHelper = $this->get($this->getCallableHelperKey($sClassName));
264
-                $xHelper->xTarget = $this->xTarget;
265
-
266
-                // Call the protected "initComponent()" method of the Component class.
267
-                $cSetter = function($di, $xHelper) {
268
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
269
-                };
270
-                $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
271
-                call_user_func($cSetter, $this->di, $xHelper);
272
-            }
273
-
274
-            // Run the callbacks for class initialisation
275
-            $this->di->g(CallbackManager::class)->onInit($xClassInstance);
276
-
277
-            // Set attributes from the DI container.
278
-            // The class level DI options are set on any component.
279
-            // The method level DI options are set only on the targetted component.
280
-            /** @var CallableObject */
281
-            $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
282
-            $xCallableObject->setDiClassAttributes($xClassInstance);
283
-            if($this->xTarget !== null)
284
-            {
285
-                $sMethodName = $this->xTarget->getMethodName();
286
-                $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
287
-            }
288
-
289
-            return $xClassInstance;
290
-        });
291
-
292
-        return $sClassName;
293
-    }
228
+private function _registerComponent(string $sComponentId): string
229
+{
230
+// Replace all separators ('.' or '_') with antislashes, and trim the class name.
231
+$sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
232
+
233
+$sComponentObject = $this->getCallableObjectKey($sClassName);
234
+// Prevent duplication. It's important not to use the class name here.
235
+if($this->has($sComponentObject))
236
+{
237
+return $sClassName;
238
+}
239
+
240
+// Register the helper class
241
+$this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
242
+$xFactory = $this->di->getCallFactory();
243
+return new ComponentHelper($this, $xFactory->rq($sClassName),
244
+    $xFactory, $this->di->getViewRenderer(),
245
+    $this->di->getLogger(), $this->di->getSessionManager(),
246
+    $this->di->getStash(), $this->di->getUploadHandler());
247
+});
248
+
249
+$this->discoverComponent($sClassName);
250
+
251
+// Register the callable object
252
+$this->set($sComponentObject, function() use($sComponentId, $sClassName) {
253
+$aOptions = $this->_getClassOptions($sComponentId);
254
+$xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
255
+$xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
256
+return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
257
+});
258
+
259
+// Initialize the user class instance
260
+$this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
261
+if($xClassInstance instanceof AbstractComponent)
262
+{
263
+    $xHelper = $this->get($this->getCallableHelperKey($sClassName));
264
+    $xHelper->xTarget = $this->xTarget;
265
+
266
+    // Call the protected "initComponent()" method of the Component class.
267
+    $cSetter = function($di, $xHelper) {
268
+        $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
269
+    };
270
+    $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
271
+    call_user_func($cSetter, $this->di, $xHelper);
272
+}
273
+
274
+// Run the callbacks for class initialisation
275
+$this->di->g(CallbackManager::class)->onInit($xClassInstance);
276
+
277
+// Set attributes from the DI container.
278
+// The class level DI options are set on any component.
279
+// The method level DI options are set only on the targetted component.
280
+/** @var CallableObject */
281
+$xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
282
+$xCallableObject->setDiClassAttributes($xClassInstance);
283
+if($this->xTarget !== null)
284
+{
285
+    $sMethodName = $this->xTarget->getMethodName();
286
+    $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
287
+}
288
+
289
+return $xClassInstance;
290
+});
291
+
292
+return $sClassName;
293
+}
294 294
 
295
-    /**
295
+/**
296 296
      * Get the callable object for a given class
297 297
      * The callable object is registered if it is not already in the DI.
298 298
      *
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
      * @return CallableObject|null
302 302
      * @throws SetupException
303 303
      */
304
-    public function makeCallableObject(string $sComponentId): ?CallableObject
305
-    {
306
-        $sClassName = $this->_registerComponent($sComponentId);
307
-        return $this->get($this->getCallableObjectKey($sClassName));
308
-    }
304
+public function makeCallableObject(string $sComponentId): ?CallableObject
305
+{
306
+$sClassName = $this->_registerComponent($sComponentId);
307
+return $this->get($this->getCallableObjectKey($sClassName));
308
+}
309 309
 
310
-    /**
310
+/**
311 311
      * Get an instance of a component by name
312 312
      *
313 313
      * @template T
@@ -316,53 +316,53 @@  discard block
 block discarded – undo
316 316
      * @return T|null
317 317
      * @throws SetupException
318 318
      */
319
-    public function makeComponent(string $sClassName): mixed
320
-    {
321
-        $sComponentId = str_replace('\\', '.', $sClassName);
322
-        $sClassName = $this->_registerComponent($sComponentId);
323
-        return $this->get($sClassName);
324
-    }
319
+public function makeComponent(string $sClassName): mixed
320
+{
321
+$sComponentId = str_replace('\\', '.', $sClassName);
322
+$sClassName = $this->_registerComponent($sComponentId);
323
+return $this->get($sClassName);
324
+}
325 325
 
326
-    /**
326
+/**
327 327
      * Get a factory for a call to a registered function.
328 328
      *
329 329
      * @return JxnCall
330 330
      */
331
-    public function getFunctionRequestFactory(): JxnCall
332
-    {
333
-        return $this->get($this->getRequestFactoryKey(JxnCall::class));
334
-    }
331
+public function getFunctionRequestFactory(): JxnCall
332
+{
333
+return $this->get($this->getRequestFactoryKey(JxnCall::class));
334
+}
335 335
 
336
-    /**
336
+/**
337 337
      * Get a factory for a call to a registered component.
338 338
      *
339 339
      * @param class-string $sClassName
340 340
      *
341 341
      * @return JxnCall|null
342 342
      */
343
-    public function getComponentRequestFactory(string $sClassName): ?JxnCall
343
+public function getComponentRequestFactory(string $sClassName): ?JxnCall
344
+{
345
+$sClassName = trim($sClassName, " \t");
346
+if($sClassName === '')
347
+{
348
+return null;
349
+}
350
+
351
+$sFactoryKey = $this->getRequestFactoryKey($sClassName);
352
+if(!$this->has($sFactoryKey))
353
+{
354
+$this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
355
+    $sComponentId = str_replace('\\', '.', $sClassName);
356
+    if(!($xCallable = $this->makeCallableObject($sComponentId)))
344 357
     {
345
-        $sClassName = trim($sClassName, " \t");
346
-        if($sClassName === '')
347
-        {
348
-            return null;
349
-        }
350
-
351
-        $sFactoryKey = $this->getRequestFactoryKey($sClassName);
352
-        if(!$this->has($sFactoryKey))
353
-        {
354
-            $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
355
-                $sComponentId = str_replace('\\', '.', $sClassName);
356
-                if(!($xCallable = $this->makeCallableObject($sComponentId)))
357
-                {
358
-                    return null;
359
-                }
360
-
361
-                $xConfigManager = $this->di->g(ConfigManager::class);
362
-                $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
363
-                return new JxnClassCall($sPrefix . $xCallable->getJsName());
364
-            });
365
-        }
366
-        return $this->get($sFactoryKey);
358
+        return null;
367 359
     }
360
+
361
+    $xConfigManager = $this->di->g(ConfigManager::class);
362
+    $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
363
+    return new JxnClassCall($sPrefix . $xCallable->getJsName());
364
+});
365
+}
366
+return $this->get($sFactoryKey);
367
+}
368 368
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         // Register the logger component, and export to js.
84 84
         $this->di->callback()->boot(function() {
85
-            if($this->di->config()->loggingEnabled())
85
+            if ($this->di->config()->loggingEnabled())
86 86
             {
87 87
                 $this->saveComponent(LoggerComponent::class, [
88 88
                     'separator' => '.',
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
         try
190 190
         {
191 191
             // Make sure the registered class exists
192
-            if(isset($aOptions['include']))
192
+            if (isset($aOptions['include']))
193 193
             {
194 194
                 require_once $aOptions['include'];
195 195
             }
196 196
             $xReflectionClass = new ReflectionClass($sClassName);
197 197
             // Check if the class is registrable
198
-            if(!$xReflectionClass->isInstantiable())
198
+            if (!$xReflectionClass->isInstantiable())
199 199
             {
200 200
                 return;
201 201
             }
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
             $sClassKey = $this->getReflectionClassKey($sClassName);
206 206
             $this->val($sClassKey, $xReflectionClass);
207 207
             // Register the user class, but only if the user didn't already.
208
-            if(!$this->has($sClassName))
208
+            if (!$this->has($sClassName))
209 209
             {
210 210
                 $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
211 211
             }
212 212
         }
213
-        catch(ReflectionException $e)
213
+        catch (ReflectionException $e)
214 214
         {
215 215
             throw new SetupException($this->cn()->g(Translator::class)
216 216
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
         $sComponentObject = $this->getCallableObjectKey($sClassName);
234 234
         // Prevent duplication. It's important not to use the class name here.
235
-        if($this->has($sComponentObject))
235
+        if ($this->has($sComponentObject))
236 236
         {
237 237
             return $sClassName;
238 238
         }
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 
259 259
         // Initialize the user class instance
260 260
         $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
261
-            if($xClassInstance instanceof AbstractComponent)
261
+            if ($xClassInstance instanceof AbstractComponent)
262 262
             {
263 263
                 $xHelper = $this->get($this->getCallableHelperKey($sClassName));
264 264
                 $xHelper->xTarget = $this->xTarget;
265 265
 
266 266
                 // Call the protected "initComponent()" method of the Component class.
267 267
                 $cSetter = function($di, $xHelper) {
268
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
268
+                    $this->initComponent($di, $xHelper); // "$this" here refers to the Component class.
269 269
                 };
270 270
                 $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
271 271
                 call_user_func($cSetter, $this->di, $xHelper);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             /** @var CallableObject */
281 281
             $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
282 282
             $xCallableObject->setDiClassAttributes($xClassInstance);
283
-            if($this->xTarget !== null)
283
+            if ($this->xTarget !== null)
284 284
             {
285 285
                 $sMethodName = $this->xTarget->getMethodName();
286 286
                 $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
     public function getComponentRequestFactory(string $sClassName): ?JxnCall
344 344
     {
345 345
         $sClassName = trim($sClassName, " \t");
346
-        if($sClassName === '')
346
+        if ($sClassName === '')
347 347
         {
348 348
             return null;
349 349
         }
350 350
 
351 351
         $sFactoryKey = $this->getRequestFactoryKey($sClassName);
352
-        if(!$this->has($sFactoryKey))
352
+        if (!$this->has($sFactoryKey))
353 353
         {
354 354
             $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
355 355
                 $sComponentId = str_replace('\\', '.', $sClassName);
356
-                if(!($xCallable = $this->makeCallableObject($sComponentId)))
356
+                if (!($xCallable = $this->makeCallableObject($sComponentId)))
357 357
                 {
358 358
                     return null;
359 359
                 }
Please login to merge, or discard this patch.
jaxon-core/src/Jaxon.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
 
17 17
 class Jaxon
18 18
 {
19
-    /**
19
+/**
20 20
      * @const string
21 21
      */
22
-    public const VERSION = 'Jaxon 5.x';
22
+public const VERSION = 'Jaxon 5.x';
23 23
 
24
-    /**
24
+/**
25 25
      * @const string
26 26
      */
27
-    public const CALLABLE_CLASS = 'CallableClass';
27
+public const CALLABLE_CLASS = 'CallableClass';
28 28
 
29
-    /**
29
+/**
30 30
      * @const string
31 31
      */
32
-    public const CALLABLE_DIR = 'CallableDir';
32
+public const CALLABLE_DIR = 'CallableDir';
33 33
 
34
-    /**
34
+/**
35 35
      * @const string
36 36
      */
37
-    public const CALLABLE_FUNCTION = 'CallableFunction';
37
+public const CALLABLE_FUNCTION = 'CallableFunction';
38 38
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Target.php 1 patch
Switch Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,56 +17,56 @@  discard block
 block discarded – undo
17 17
 
18 18
 class Target implements TargetInterface
19 19
 {
20
-    /**
20
+/**
21 21
      * The target type for function.
22 22
      *
23 23
      * @var string
24 24
      */
25
-    const TYPE_FUNCTION = 'TargetFunction';
25
+const TYPE_FUNCTION = 'TargetFunction';
26 26
 
27
-    /**
27
+/**
28 28
      * The target type for class.
29 29
      *
30 30
      * @var string
31 31
      */
32
-    const TYPE_CLASS = 'TargetClass';
32
+const TYPE_CLASS = 'TargetClass';
33 33
 
34
-    /**
34
+/**
35 35
      * The target type.
36 36
      *
37 37
      * @var string
38 38
      */
39
-    private $sType = '';
39
+private $sType = '';
40 40
 
41
-    /**
41
+/**
42 42
      * The target function name.
43 43
      *
44 44
      * @var string
45 45
      */
46
-    private $sFunctionName = '';
46
+private $sFunctionName = '';
47 47
 
48
-    /**
48
+/**
49 49
      * The target class name.
50 50
      *
51 51
      * @var string
52 52
      */
53
-    private $sClassName = '';
53
+private $sClassName = '';
54 54
 
55
-    /**
55
+/**
56 56
      * The target method name.
57 57
      *
58 58
      * @var string
59 59
      */
60
-    private $sMethodName = '';
60
+private $sMethodName = '';
61 61
 
62
-    /**
62
+/**
63 63
      * The target method args.
64 64
      *
65 65
      * @var array
66 66
      */
67
-    private $aMethodArgs = [];
67
+private $aMethodArgs = [];
68 68
 
69
-    /**
69
+/**
70 70
      * The constructor
71 71
      *
72 72
      * @param string $sType    The target type
@@ -75,116 +75,116 @@  discard block
 block discarded – undo
75 75
      * @param string $sMethodName    The method name
76 76
      * @param array $aMethodArgs    The method args
77 77
      */
78
-    private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = [])
79
-    {
80
-        $this->sType = $sType;
81
-        $this->sFunctionName = $sFunctionName;
82
-        $this->sClassName = $sClassName;
83
-        $this->sMethodName = $sMethodName;
84
-        $this->aMethodArgs = $aMethodArgs;
85
-    }
78
+private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = [])
79
+{
80
+$this->sType = $sType;
81
+$this->sFunctionName = $sFunctionName;
82
+$this->sClassName = $sClassName;
83
+$this->sMethodName = $sMethodName;
84
+$this->aMethodArgs = $aMethodArgs;
85
+}
86 86
 
87
-    /**
87
+/**
88 88
      * Create a target of type Function
89 89
      *
90 90
      * @param string $sFunctionName    The function name
91 91
      *
92 92
      * @return Target
93 93
      */
94
-    public static function makeFunction(string $sFunctionName): Target
95
-    {
96
-        return new Target(self::TYPE_FUNCTION, $sFunctionName, '', '');
97
-    }
94
+public static function makeFunction(string $sFunctionName): Target
95
+{
96
+return new Target(self::TYPE_FUNCTION, $sFunctionName, '', '');
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * Create a target of type Class
101 101
      *
102 102
      * @param array $aCall
103 103
      *
104 104
      * @return Target
105 105
      */
106
-    public static function makeClass(array $aCall): Target
107
-    {
108
-        return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method']));
109
-    }
106
+public static function makeClass(array $aCall): Target
107
+{
108
+return new Target(self::TYPE_CLASS, '', trim($aCall['name']), trim($aCall['method']));
109
+}
110 110
 
111
-    /**
111
+/**
112 112
      * Check if the target type is Function.
113 113
      *
114 114
      * @return bool
115 115
      */
116
-    public function isFunction(): bool
117
-    {
118
-        return $this->sType === self::TYPE_FUNCTION;
119
-    }
116
+public function isFunction(): bool
117
+{
118
+return $this->sType === self::TYPE_FUNCTION;
119
+}
120 120
 
121
-    /**
121
+/**
122 122
      * Check if the target type is Class.
123 123
      *
124 124
      * @return bool
125 125
      */
126
-    public function isClass(): bool
127
-    {
128
-        return $this->sType === self::TYPE_CLASS;
129
-    }
126
+public function isClass(): bool
127
+{
128
+return $this->sType === self::TYPE_CLASS;
129
+}
130 130
 
131
-    /**
131
+/**
132 132
      * The target function name.
133 133
      *
134 134
      * @return string
135 135
      */
136
-    public function getFunctionName(): string
137
-    {
138
-        return $this->sFunctionName;
139
-    }
136
+public function getFunctionName(): string
137
+{
138
+return $this->sFunctionName;
139
+}
140 140
 
141
-    /**
141
+/**
142 142
      * The target class name.
143 143
      *
144 144
      * @return string
145 145
      */
146
-    public function getClassName(): string
147
-    {
148
-        return $this->sClassName;
149
-    }
146
+public function getClassName(): string
147
+{
148
+return $this->sClassName;
149
+}
150 150
 
151
-    /**
151
+/**
152 152
      * The target method name.
153 153
      *
154 154
      * @return string
155 155
      */
156
-    public function getMethodName(): string
157
-    {
158
-        return $this->sMethodName;
159
-    }
156
+public function getMethodName(): string
157
+{
158
+return $this->sMethodName;
159
+}
160 160
 
161
-    /**
161
+/**
162 162
      * Set the target method name.
163 163
      *
164 164
      * @param array $aMethodArgs
165 165
      */
166
-    public function setMethodArgs(array $aMethodArgs): void
167
-    {
168
-        $this->aMethodArgs = $aMethodArgs;
169
-    }
166
+public function setMethodArgs(array $aMethodArgs): void
167
+{
168
+$this->aMethodArgs = $aMethodArgs;
169
+}
170 170
 
171
-    /**
171
+/**
172 172
      * The target method name.
173 173
      *
174 174
      * @return string
175 175
      */
176
-    public function method(): string
177
-    {
178
-        return $this->sMethodName;
179
-    }
176
+public function method(): string
177
+{
178
+return $this->sMethodName;
179
+}
180 180
 
181
-    /**
181
+/**
182 182
      * The target method args.
183 183
      *
184 184
      * @return array
185 185
      */
186
-    public function args(): array
187
-    {
188
-        return $this->aMethodArgs;
189
-    }
186
+public function args(): array
187
+{
188
+return $this->aMethodArgs;
189
+}
190 190
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/ComponentRegistry.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     public function __construct(protected ComponentContainer $cdi)
111 111
     {
112 112
         // Set the composer autoloader
113
-        if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
113
+        if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
114 114
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../../vendor/autoload.php')) ||
115 115
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php')))
116 116
         {
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array
181 181
     {
182
-        foreach($this->aDefaultClassOptions as $sOption => $xValue)
182
+        foreach ($this->aDefaultClassOptions as $sOption => $xValue)
183 183
         {
184
-            if(!isset($aClassOptions[$sOption]))
184
+            if (!isset($aClassOptions[$sOption]))
185 185
             {
186 186
                 $aClassOptions[$sOption] = $xValue;
187 187
             }
188 188
         }
189 189
         $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool.
190
-        if(is_string($aClassOptions['protected']))
190
+        if (is_string($aClassOptions['protected']))
191 191
         {
192 192
             $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array.
193 193
         }
@@ -198,30 +198,30 @@  discard block
 block discarded – undo
198 198
             $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes
199 199
             $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class
200 200
         ];
201
-        foreach($aOptionGroups as $aOptionGroup)
201
+        foreach ($aOptionGroups as $aOptionGroup)
202 202
         {
203
-            if(isset($aOptionGroup['separator']))
203
+            if (isset($aOptionGroup['separator']))
204 204
             {
205 205
                 $aClassOptions['separator'] = (string)$aOptionGroup['separator'];
206 206
             }
207
-            if(isset($aOptionGroup['excluded']))
207
+            if (isset($aOptionGroup['excluded']))
208 208
             {
209 209
                 $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded'];
210 210
             }
211
-            if(isset($aOptionGroup['protected']))
211
+            if (isset($aOptionGroup['protected']))
212 212
             {
213
-                if(is_string($aOptionGroup['protected']))
213
+                if (is_string($aOptionGroup['protected']))
214 214
                 {
215 215
                     $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array.
216 216
                 }
217 217
                 $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']);
218 218
             }
219
-            if(isset($aOptionGroup['functions']))
219
+            if (isset($aOptionGroup['functions']))
220 220
             {
221 221
                 $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']);
222 222
             }
223 223
         }
224
-        if(isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
224
+        if (isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
225 225
         {
226 226
             $aClassOptions['config'] = $aDirectoryOptions['config'];
227 227
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $aOptions = $this->makeClassOptions($sClassName, $aClassOptions, $aDirectoryOptions);
245 245
         $this->cdi->saveComponent($sClassName, $aOptions);
246
-        if($this->bUpdateHash)
246
+        if ($this->bUpdateHash)
247 247
         {
248 248
             $this->sHash .= $sClassName . $aOptions['timestamp'];
249 249
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     {
262 262
         // For classes, the underscore is used as separator.
263 263
         $aClassOptions['separator'] = '_';
264
-        if($this->xPackageConfig !== null)
264
+        if ($this->xPackageConfig !== null)
265 265
         {
266 266
             $aClassOptions['config'] = $this->xPackageConfig;
267 267
         }
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
     public function getNamespaceComponentOptions(string $sClassName): ?array
279 279
     {
280 280
         // Find the corresponding namespace
281
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
281
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
282 282
         {
283 283
             // Check if the namespace matches the class.
284
-            if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
284
+            if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
285 285
             {
286 286
                 // Save the class options
287 287
                 $aClassOptions = ['namespace' => $sNamespace];
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
         // For directories without namespace, the underscore is used as separator.
305 305
         $aOptions['separator'] = '_';
306 306
         // Set the autoload option default value
307
-        if(!isset($aOptions['autoload']))
307
+        if (!isset($aOptions['autoload']))
308 308
         {
309 309
             $aOptions['autoload'] = true;
310 310
         }
311
-        if($this->xPackageConfig !== null)
311
+        if ($this->xPackageConfig !== null)
312 312
         {
313 313
             $aOptions['config'] = $this->xPackageConfig;
314 314
         }
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
         // For namespaces, the dot is used as separator.
343 343
         $aOptions['separator'] = '.';
344 344
         // Set the autoload option default value
345
-        if(!isset($aOptions['autoload']))
345
+        if (!isset($aOptions['autoload']))
346 346
         {
347 347
             $aOptions['autoload'] = true;
348 348
         }
349
-        if($this->xPackageConfig !== null)
349
+        if ($this->xPackageConfig !== null)
350 350
         {
351 351
             $aOptions['config'] = $this->xPackageConfig;
352 352
         }
353 353
         // Register the dir with PSR4 autoloading
354
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
354
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
355 355
         {
356 356
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
357 357
         }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function registerComponentsInNamespaces(): void
368 368
     {
369 369
         // This is to be done only once.
370
-        if($this->bNamespacesParsed)
370
+        if ($this->bNamespacesParsed)
371 371
         {
372 372
             return;
373 373
         }
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 
376 376
         // Browse directories with namespaces and read all the files.
377 377
         $sDS = DIRECTORY_SEPARATOR;
378
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
378
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
379 379
         {
380 380
             $this->addNamespace($sNamespace, ['separator' => '.']);
381 381
 
382 382
             // Iterate on dir content
383 383
             $sDirectory = $aDirectoryOptions['directory'];
384 384
             $itFile = new SortedFileIterator($sDirectory);
385
-            foreach($itFile as $xFile)
385
+            foreach ($itFile as $xFile)
386 386
             {
387 387
                 // skip everything except PHP files
388
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
388
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
389 389
                 {
390 390
                     continue;
391 391
                 }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                 $sClassPath = $sNamespace;
395 395
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
396 396
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
397
-                if($sRelativePath !== '')
397
+                if ($sRelativePath !== '')
398 398
                 {
399 399
                     $sClassPath .= '\\' . $sRelativePath;
400 400
                 }
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
     public function registerComponentsInDirectories(): void
421 421
     {
422 422
         // This is to be done only once.
423
-        if($this->bDirectoriesParsed)
423
+        if ($this->bDirectoriesParsed)
424 424
         {
425 425
             return;
426 426
         }
427 427
         $this->bDirectoriesParsed = true;
428 428
 
429 429
         // Browse directories without namespaces and read all the files.
430
-        foreach($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
430
+        foreach ($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
431 431
         {
432 432
             $itFile = new SortedFileIterator($sDirectory);
433 433
             // Iterate on dir content
434
-            foreach($itFile as $xFile)
434
+            foreach ($itFile as $xFile)
435 435
             {
436 436
                 // Skip everything except PHP files
437
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
437
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
438 438
                 {
439 439
                     continue;
440 440
                 }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                     'separator' => '.',
445 445
                     'timestamp' => $xFile->getMTime(),
446 446
                 ];
447
-                if(($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
447
+                if (($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
448 448
                 {
449 449
                     // Set classmap autoloading. Must be done before registering the class.
450 450
                     $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]);
Please login to merge, or discard this patch.
jaxon-core/src/App/Databag/Databag.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     public function new(string $sBag, string $sKey, $xValue): void
91 91
     {
92 92
         // Set the value only if it doesn't already exist.
93
-        if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
93
+        if (!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
94 94
         {
95 95
             $this->set($sBag, $sKey, $xValue);
96 96
         }
Please login to merge, or discard this patch.
Switch Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -11,110 +11,110 @@
 block discarded – undo
11 11
 
12 12
 class Databag implements JsonSerializable
13 13
 {
14
-    /**
14
+/**
15 15
      * @var DatabagPlugin
16 16
      */
17
-    protected $xPlugin;
17
+protected $xPlugin;
18 18
 
19
-    /**
19
+/**
20 20
      * @var array
21 21
      */
22
-    protected $aData = [];
22
+protected $aData = [];
23 23
 
24
-    /**
24
+/**
25 25
      * @var bool
26 26
      */
27
-    protected $bTouched = false;
27
+protected $bTouched = false;
28 28
 
29
-    /**
29
+/**
30 30
      * The constructor
31 31
      *
32 32
      * @param array $aData
33 33
      */
34
-    public function __construct(DatabagPlugin $xPlugin, array $aData)
35
-    {
36
-        $this->xPlugin = $xPlugin;
37
-        // Ensure all contents are arrays.
38
-        $this->aData = array_map(function($aValue) {
39
-            return is_array($aValue) ? $aValue : [];
40
-        }, $aData);
41
-    }
34
+public function __construct(DatabagPlugin $xPlugin, array $aData)
35
+{
36
+$this->xPlugin = $xPlugin;
37
+// Ensure all contents are arrays.
38
+$this->aData = array_map(function($aValue) {
39
+return is_array($aValue) ? $aValue : [];
40
+}, $aData);
41
+}
42 42
 
43
-    /**
43
+/**
44 44
      * @return bool
45 45
      */
46
-    public function touched(): bool
47
-    {
48
-        return $this->bTouched;
49
-    }
46
+public function touched(): bool
47
+{
48
+return $this->bTouched;
49
+}
50 50
 
51
-    /**
51
+/**
52 52
      * @return array
53 53
      */
54
-    public function getAll(): array
55
-    {
56
-        return $this->aData;
57
-    }
54
+public function getAll(): array
55
+{
56
+return $this->aData;
57
+}
58 58
 
59
-    /**
59
+/**
60 60
      * @param string $sBag
61 61
      *
62 62
      * @return void
63 63
      */
64
-    public function clear(string $sBag): void
65
-    {
66
-        $this->aData[$sBag] = [];
67
-        $this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]);
68
-    }
64
+public function clear(string $sBag): void
65
+{
66
+$this->aData[$sBag] = [];
67
+$this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]);
68
+}
69 69
 
70
-    /**
70
+/**
71 71
      * @param string $sBag
72 72
      * @param string $sKey
73 73
      * @param mixed $xValue
74 74
      *
75 75
      * @return void
76 76
      */
77
-    public function set(string $sBag, string $sKey, $xValue): void
78
-    {
79
-        $this->bTouched = true;
80
-        $this->aData[$sBag][$sKey] = $xValue;
81
-    }
77
+public function set(string $sBag, string $sKey, $xValue): void
78
+{
79
+$this->bTouched = true;
80
+$this->aData[$sBag][$sKey] = $xValue;
81
+}
82 82
 
83
-    /**
83
+/**
84 84
      * @param string $sBag
85 85
      * @param string $sKey
86 86
      * @param mixed $xValue
87 87
      *
88 88
      * @return void
89 89
      */
90
-    public function new(string $sBag, string $sKey, $xValue): void
91
-    {
92
-        // Set the value only if it doesn't already exist.
93
-        if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
94
-        {
95
-            $this->set($sBag, $sKey, $xValue);
96
-        }
97
-    }
90
+public function new(string $sBag, string $sKey, $xValue): void
91
+{
92
+// Set the value only if it doesn't already exist.
93
+if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
94
+{
95
+$this->set($sBag, $sKey, $xValue);
96
+}
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * @param string $sBag
101 101
      * @param string $sKey
102 102
      * @param mixed $xValue
103 103
      *
104 104
      * @return mixed
105 105
      */
106
-    public function get(string $sBag, string $sKey, $xValue = null): mixed
107
-    {
108
-        return $this->aData[$sBag][$sKey] ?? $xValue;
109
-    }
106
+public function get(string $sBag, string $sKey, $xValue = null): mixed
107
+{
108
+return $this->aData[$sBag][$sKey] ?? $xValue;
109
+}
110 110
 
111
-    /**
111
+/**
112 112
      * Convert this call to array, when converting the response into json.
113 113
      *
114 114
      * @return array
115 115
      */
116
-    public function jsonSerialize(): array
117
-    {
118
-        return $this->aData;
119
-    }
116
+public function jsonSerialize(): array
117
+{
118
+return $this->aData;
119
+}
120 120
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Databag/DatabagPlugin.php 2 patches
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.
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.
jaxon-attributes/src/Attribute/Databag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 use Jaxon\App\Metadata\Metadata;
19 19
 use Attribute;
20 20
 
21
-#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
21
+#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
22 22
 class Databag extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-annotations/src/Annotation/DatabagAnnotation.php 2 patches
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,40 +28,40 @@
 block discarded – undo
28 28
  */
29 29
 class DatabagAnnotation extends AbstractAnnotation
30 30
 {
31
-    /**
31
+/**
32 32
      * The data bag name
33 33
      *
34 34
      * @var string
35 35
      */
36
-    protected $sName = '';
36
+protected $sName = '';
37 37
 
38
-    /**
38
+/**
39 39
      * @inheritDoc
40 40
      */
41
-    public static function parseAnnotation($value)
42
-    {
43
-        $aParams = preg_split('/[\s]+/', $value, 2);
44
-        return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]];
45
-    }
41
+public static function parseAnnotation($value)
42
+{
43
+$aParams = preg_split('/[\s]+/', $value, 2);
44
+return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]];
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @inheritDoc
49 49
      * @throws AnnotationException
50 50
      */
51
-    public function initAnnotation(array $properties)
52
-    {
53
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54
-        {
55
-            throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56
-        }
57
-        $this->sName = $properties['name'];
58
-    }
51
+public function initAnnotation(array $properties)
52
+{
53
+if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54
+{
55
+throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56
+}
57
+$this->sName = $properties['name'];
58
+}
59 59
 
60
-    /**
60
+/**
61 61
      * @inheritDoc
62 62
      */
63
-    public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
64
-    {
65
-        $xMetadata->databag($sMethod)->addValue($this->sName);
66
-    }
63
+public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
64
+{
65
+$xMetadata->databag($sMethod)->addValue($this->sName);
66
+}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
      */
51 51
     public function initAnnotation(array $properties)
52 52
     {
53
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
53
+        if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54 54
         {
55 55
             throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56 56
         }
Please login to merge, or discard this patch.
jaxon-core/src/App/Databag/DatabagContext.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,58 +4,58 @@
 block discarded – undo
4 4
 
5 5
 class DatabagContext
6 6
 {
7
-    /**
7
+/**
8 8
      * @var Databag
9 9
      */
10
-    protected $xDatabag;
10
+protected $xDatabag;
11 11
 
12
-    /**
12
+/**
13 13
      * @var string
14 14
      */
15
-    protected $sName;
15
+protected $sName;
16 16
 
17
-    /**
17
+/**
18 18
      * The constructor
19 19
      *
20 20
      * @param Databag $xDatabag
21 21
      * @param string $sName
22 22
      */
23
-    public function __construct(Databag $xDatabag, string $sName)
24
-    {
25
-        $this->xDatabag = $xDatabag;
26
-        $this->sName = $sName;
27
-    }
23
+public function __construct(Databag $xDatabag, string $sName)
24
+{
25
+$this->xDatabag = $xDatabag;
26
+$this->sName = $sName;
27
+}
28 28
 
29
-    /**
29
+/**
30 30
      * @param string $sKey
31 31
      * @param mixed $xValue
32 32
      *
33 33
      * @return void
34 34
      */
35
-    public function set(string $sKey, $xValue): void
36
-    {
37
-        $this->xDatabag->set($this->sName, $sKey, $xValue);
38
-    }
35
+public function set(string $sKey, $xValue): void
36
+{
37
+$this->xDatabag->set($this->sName, $sKey, $xValue);
38
+}
39 39
 
40
-    /**
40
+/**
41 41
      * @param string $sKey
42 42
      * @param mixed $xValue
43 43
      *
44 44
      * @return void
45 45
      */
46
-    public function new(string $sKey, $xValue): void
47
-    {
48
-        $this->xDatabag->new($this->sName, $sKey, $xValue);
49
-    }
46
+public function new(string $sKey, $xValue): void
47
+{
48
+$this->xDatabag->new($this->sName, $sKey, $xValue);
49
+}
50 50
 
51
-    /**
51
+/**
52 52
      * @param string $sKey
53 53
      * @param mixed $xValue
54 54
      *
55 55
      * @return mixed
56 56
      */
57
-    public function get(string $sKey, $xValue = null): mixed
58
-    {
59
-        return $this->xDatabag->get($this->sName, $sKey, $xValue);
60
-    }
57
+public function get(string $sKey, $xValue = null): mixed
58
+{
59
+return $this->xDatabag->get($this->sName, $sKey, $xValue);
60
+}
61 61
 }
Please login to merge, or discard this patch.