Passed
Push — main ( 8599f1...f44baa )
by Thierry
06:14
created
jaxon-core/src/Di/Traits/PluginTrait.php 1 patch
Switch Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -36,154 +36,154 @@  discard block
 block discarded – undo
36 36
 
37 37
 trait PluginTrait
38 38
 {
39
-    /**
39
+/**
40 40
      * Register the values into the container
41 41
      *
42 42
      * @return void
43 43
      */
44
-    private function registerPlugins(): void
45
-    {
46
-        // Plugin manager
47
-        $this->set(PluginManager::class, function($di) {
48
-            $xPluginManager = new PluginManager($di->g(Container::class),
49
-                $di->g(CodeGenerator::class), $di->g(Translator::class));
50
-            // Register the Jaxon request and response plugins
51
-            $xPluginManager->registerPlugins();
52
-            return $xPluginManager;
53
-        });
54
-        // Package manager
55
-        $this->set(PackageManager::class, function($di) {
56
-            return new PackageManager($di->g(Container::class), $di->g(Translator::class),
57
-                $di->g(PluginManager::class), $di->g(ConfigManager::class),
58
-                $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
59
-                $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
60
-        });
61
-        // Code Generation
62
-        $this->set(MinifierInterface::class, function() {
63
-            return new class extends FileMinifier implements MinifierInterface
64
-            {};
65
-        });
66
-        $this->set(AssetManager::class, function($di) {
67
-            return new AssetManager($di->g(ConfigManager::class),
68
-                $di->g(MinifierInterface::class));
69
-        });
70
-        $this->set(CodeGenerator::class, function($di) {
71
-            return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
72
-                $di->g(TemplateEngine::class));
73
-        });
74
-        $this->set(ConfigScriptGenerator::class, function($di) {
75
-            return new ConfigScriptGenerator($di->g(ParameterReader::class),
76
-                $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
77
-        });
78
-        $this->set(ReadyScriptGenerator::class, function($di) {
79
-            return new ReadyScriptGenerator();
80
-        });
81
-
82
-        // Script response plugin
83
-        $this->set(ScriptPlugin::class, function($di) {
84
-            return new ScriptPlugin($di->g(CallFactory::class));
85
-        });
86
-        // Databag response plugin. Get the databag contents from the HTTP request parameters.
87
-        $this->set(DatabagPlugin::class, function($di) {
88
-            return new DatabagPlugin(fn() => $di->getRequest()->getAttribute('jxnbags', []));
89
-        });
90
-        // Dialog response plugin
91
-        $this->set(DialogPlugin::class, function($di) {
92
-            return new DialogPlugin($di->g(DialogCommand::class));
93
-        });
94
-        // Paginator response plugin
95
-        $this->set(PaginatorPlugin::class, function($di) {
96
-            return new PaginatorPlugin($di->g(RendererInterface::class));
97
-        });
98
-    }
99
-
100
-    /**
44
+private function registerPlugins(): void
45
+{
46
+// Plugin manager
47
+$this->set(PluginManager::class, function($di) {
48
+$xPluginManager = new PluginManager($di->g(Container::class),
49
+    $di->g(CodeGenerator::class), $di->g(Translator::class));
50
+// Register the Jaxon request and response plugins
51
+$xPluginManager->registerPlugins();
52
+return $xPluginManager;
53
+});
54
+// Package manager
55
+$this->set(PackageManager::class, function($di) {
56
+return new PackageManager($di->g(Container::class), $di->g(Translator::class),
57
+    $di->g(PluginManager::class), $di->g(ConfigManager::class),
58
+    $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
59
+    $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
60
+});
61
+// Code Generation
62
+$this->set(MinifierInterface::class, function() {
63
+return new class extends FileMinifier implements MinifierInterface
64
+{};
65
+});
66
+$this->set(AssetManager::class, function($di) {
67
+return new AssetManager($di->g(ConfigManager::class),
68
+    $di->g(MinifierInterface::class));
69
+});
70
+$this->set(CodeGenerator::class, function($di) {
71
+return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
72
+    $di->g(TemplateEngine::class));
73
+});
74
+$this->set(ConfigScriptGenerator::class, function($di) {
75
+return new ConfigScriptGenerator($di->g(ParameterReader::class),
76
+    $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
77
+});
78
+$this->set(ReadyScriptGenerator::class, function($di) {
79
+return new ReadyScriptGenerator();
80
+});
81
+
82
+// Script response plugin
83
+$this->set(ScriptPlugin::class, function($di) {
84
+return new ScriptPlugin($di->g(CallFactory::class));
85
+});
86
+// Databag response plugin. Get the databag contents from the HTTP request parameters.
87
+$this->set(DatabagPlugin::class, function($di) {
88
+return new DatabagPlugin(fn() => $di->getRequest()->getAttribute('jxnbags', []));
89
+});
90
+// Dialog response plugin
91
+$this->set(DialogPlugin::class, function($di) {
92
+return new DialogPlugin($di->g(DialogCommand::class));
93
+});
94
+// Paginator response plugin
95
+$this->set(PaginatorPlugin::class, function($di) {
96
+return new PaginatorPlugin($di->g(RendererInterface::class));
97
+});
98
+}
99
+
100
+/**
101 101
      * Get the plugin manager
102 102
      *
103 103
      * @return PluginManager
104 104
      */
105
-    public function getPluginManager(): PluginManager
106
-    {
107
-        return $this->g(PluginManager::class);
108
-    }
105
+public function getPluginManager(): PluginManager
106
+{
107
+return $this->g(PluginManager::class);
108
+}
109 109
 
110
-    /**
110
+/**
111 111
      * Get the package manager
112 112
      *
113 113
      * @return PackageManager
114 114
      */
115
-    public function getPackageManager(): PackageManager
116
-    {
117
-        return $this->g(PackageManager::class);
118
-    }
115
+public function getPackageManager(): PackageManager
116
+{
117
+return $this->g(PackageManager::class);
118
+}
119 119
 
120
-    /**
120
+/**
121 121
      * Get the code generator
122 122
      *
123 123
      * @return CodeGenerator
124 124
      */
125
-    public function getCodeGenerator(): CodeGenerator
126
-    {
127
-        return $this->g(CodeGenerator::class);
128
-    }
125
+public function getCodeGenerator(): CodeGenerator
126
+{
127
+return $this->g(CodeGenerator::class);
128
+}
129 129
 
130
-    /**
130
+/**
131 131
      * Get the asset manager
132 132
      *
133 133
      * @return AssetManager
134 134
      */
135
-    public function getAssetManager(): AssetManager
136
-    {
137
-        return $this->g(AssetManager::class);
138
-    }
135
+public function getAssetManager(): AssetManager
136
+{
137
+return $this->g(AssetManager::class);
138
+}
139 139
 
140
-    /**
140
+/**
141 141
      * Get the jQuery plugin
142 142
      *
143 143
      * @return ScriptPlugin
144 144
      */
145
-    public function getScriptPlugin(): ScriptPlugin
146
-    {
147
-        return $this->g(ScriptPlugin::class);
148
-    }
145
+public function getScriptPlugin(): ScriptPlugin
146
+{
147
+return $this->g(ScriptPlugin::class);
148
+}
149 149
 
150
-    /**
150
+/**
151 151
      * Get the dialog plugin
152 152
      *
153 153
      * @return DialogPlugin
154 154
      */
155
-    public function getDialogPlugin(): DialogPlugin
156
-    {
157
-        return $this->g(DialogPlugin::class);
158
-    }
155
+public function getDialogPlugin(): DialogPlugin
156
+{
157
+return $this->g(DialogPlugin::class);
158
+}
159 159
 
160
-    /**
160
+/**
161 161
      * @param class-string $sClassName    The package class name
162 162
      *
163 163
      * @return string
164 164
      */
165
-    private function getPackageConfigKey(string $sClassName): string
166
-    {
167
-        return $sClassName . '_PackageConfig';
168
-    }
165
+private function getPackageConfigKey(string $sClassName): string
166
+{
167
+return $sClassName . '_PackageConfig';
168
+}
169 169
 
170
-    /**
170
+/**
171 171
      * @param class-string $sClassName    The package class name
172 172
      * @param-closure-this AbstractPackage $cSetter
173 173
      *
174 174
      * @return void
175 175
      */
176
-    private function extendPackage(string $sClassName, Closure $cSetter): void
177
-    {
178
-        // Initialize the package instance.
179
-        $this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
180
-            // Allow the setter to access protected attributes.
181
-            call_user_func($cSetter->bindTo($xPackage, $xPackage));
182
-            return $xPackage;
183
-        });
184
-    }
185
-
186
-    /**
176
+private function extendPackage(string $sClassName, Closure $cSetter): void
177
+{
178
+// Initialize the package instance.
179
+$this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
180
+// Allow the setter to access protected attributes.
181
+call_user_func($cSetter->bindTo($xPackage, $xPackage));
182
+return $xPackage;
183
+});
184
+}
185
+
186
+/**
187 187
      * Register a package
188 188
      *
189 189
      * @param class-string $sClassName    The package class name
@@ -192,45 +192,45 @@  discard block
 block discarded – undo
192 192
      * @return void
193 193
      * @throws SetupException
194 194
      */
195
-    public function registerPackage(string $sClassName, array $aUserOptions): void
196
-    {
197
-        // Register the user class, but only if the user didn't already.
198
-        if(!$this->h($sClassName))
199
-        {
200
-            $this->set($sClassName, fn() => $this->make($sClassName));
201
-        }
202
-
203
-        // Save the package config in the container.
204
-        $sConfigKey = $this->getPackageConfigKey($sClassName);
205
-        $this->set($sConfigKey, function($di) use($aUserOptions) {
206
-            $xOptionsProvider = $aUserOptions['provider'] ?? null;
207
-            // The user can provide a callable that returns the package options.
208
-            if(is_callable($xOptionsProvider))
209
-            {
210
-                $aUserOptions = $xOptionsProvider($aUserOptions);
211
-            }
212
-            return $di->g(ConfigManager::class)->newConfig($aUserOptions);
213
-        });
214
-
215
-        // Initialize the package instance.
216
-        $di = $this;
217
-        $this->extendPackage($sClassName, function() use($di, $sConfigKey) {
218
-            // $this here refers to the AbstractPackage instance.
219
-            $this->xPkgConfig = $di->g($sConfigKey);
220
-            $this->xRenderer = $di->g(ViewRenderer::class);
221
-            $this->init();
222
-        });
223
-    }
224
-
225
-    /**
195
+public function registerPackage(string $sClassName, array $aUserOptions): void
196
+{
197
+// Register the user class, but only if the user didn't already.
198
+if(!$this->h($sClassName))
199
+{
200
+$this->set($sClassName, fn() => $this->make($sClassName));
201
+}
202
+
203
+// Save the package config in the container.
204
+$sConfigKey = $this->getPackageConfigKey($sClassName);
205
+$this->set($sConfigKey, function($di) use($aUserOptions) {
206
+$xOptionsProvider = $aUserOptions['provider'] ?? null;
207
+// The user can provide a callable that returns the package options.
208
+if(is_callable($xOptionsProvider))
209
+{
210
+    $aUserOptions = $xOptionsProvider($aUserOptions);
211
+}
212
+return $di->g(ConfigManager::class)->newConfig($aUserOptions);
213
+});
214
+
215
+// Initialize the package instance.
216
+$di = $this;
217
+$this->extendPackage($sClassName, function() use($di, $sConfigKey) {
218
+// $this here refers to the AbstractPackage instance.
219
+$this->xPkgConfig = $di->g($sConfigKey);
220
+$this->xRenderer = $di->g(ViewRenderer::class);
221
+$this->init();
222
+});
223
+}
224
+
225
+/**
226 226
      * Get the config of a package
227 227
      *
228 228
      * @param class-string $sClassName    The package class name
229 229
      *
230 230
      * @return Config
231 231
      */
232
-    public function getPackageConfig(string $sClassName): Config
233
-    {
234
-        return $this->g($this->getPackageConfigKey($sClassName));
235
-    }
232
+public function getPackageConfig(string $sClassName): Config
233
+{
234
+return $this->g($this->getPackageConfigKey($sClassName));
235
+}
236 236
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Databag/DatabagContext.php 1 patch
Switch Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,54 +4,54 @@
 block discarded – undo
4 4
 
5 5
 class DatabagContext
6 6
 {
7
-    /**
7
+/**
8 8
      * The constructor
9 9
      *
10 10
      * @param Databag $xDatabag
11 11
      * @param string $sName
12 12
      */
13
-    public function __construct(protected Databag $xDatabag, protected string $sName)
14
-    {}
13
+public function __construct(protected Databag $xDatabag, protected string $sName)
14
+{}
15 15
 
16
-    /**
16
+/**
17 17
      * @param string $sKey
18 18
      * @param mixed $xValue
19 19
      *
20 20
      * @return void
21 21
      */
22
-    public function set(string $sKey, $xValue): void
23
-    {
24
-        $this->xDatabag->set($this->sName, $sKey, $xValue);
25
-    }
22
+public function set(string $sKey, $xValue): void
23
+{
24
+$this->xDatabag->set($this->sName, $sKey, $xValue);
25
+}
26 26
 
27
-    /**
27
+/**
28 28
      * @param string $sKey
29 29
      * @param mixed $xValue
30 30
      *
31 31
      * @return void
32 32
      */
33
-    public function new(string $sKey, $xValue): void
34
-    {
35
-        $this->xDatabag->new($this->sName, $sKey, $xValue);
36
-    }
33
+public function new(string $sKey, $xValue): void
34
+{
35
+$this->xDatabag->new($this->sName, $sKey, $xValue);
36
+}
37 37
 
38
-    /**
38
+/**
39 39
      * @param string $sKey
40 40
      * @param mixed $xValue
41 41
      *
42 42
      * @return mixed
43 43
      */
44
-    public function get(string $sKey, $xValue = null): mixed
45
-    {
46
-        return $this->xDatabag->get($this->sName, $sKey, $xValue);
47
-    }
44
+public function get(string $sKey, $xValue = null): mixed
45
+{
46
+return $this->xDatabag->get($this->sName, $sKey, $xValue);
47
+}
48 48
 
49
-    /**
49
+/**
50 50
      * @return self
51 51
      */
52
-    public function clear(): self
53
-    {
54
-        $this->xDatabag->clear($this->sName);
55
-        return $this;
56
-    }
52
+public function clear(): self
53
+{
54
+$this->xDatabag->clear($this->sName);
55
+return $this;
56
+}
57 57
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Databag/Databag.php 1 patch
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -8,94 +8,94 @@
 block discarded – undo
8 8
 
9 9
 class Databag implements JsonSerializable
10 10
 {
11
-    /**
11
+/**
12 12
      * @var bool
13 13
      */
14
-    protected $bTouched = false;
14
+protected $bTouched = false;
15 15
 
16
-    /**
16
+/**
17 17
      * The constructor
18 18
      *
19 19
      * @param array $aData
20 20
      */
21
-    public function __construct(protected array $aData)
22
-    {}
21
+public function __construct(protected array $aData)
22
+{}
23 23
 
24
-    /**
24
+/**
25 25
      * @return bool
26 26
      */
27
-    public function touched(): bool
28
-    {
29
-        return $this->bTouched;
30
-    }
27
+public function touched(): bool
28
+{
29
+return $this->bTouched;
30
+}
31 31
 
32
-    /**
32
+/**
33 33
      * @return array
34 34
      */
35
-    public function getAll(): array
36
-    {
37
-        return $this->aData;
38
-    }
35
+public function getAll(): array
36
+{
37
+return $this->aData;
38
+}
39 39
 
40
-    /**
40
+/**
41 41
      * @param string $sBag
42 42
      *
43 43
      * @return void
44 44
      */
45
-    public function clear(string $sBag): void
46
-    {
47
-        $this->bTouched = true;
48
-        $this->aData[$sBag] = [];
49
-    }
45
+public function clear(string $sBag): void
46
+{
47
+$this->bTouched = true;
48
+$this->aData[$sBag] = [];
49
+}
50 50
 
51
-    /**
51
+/**
52 52
      * @param string $sBag
53 53
      * @param string $sKey
54 54
      * @param mixed $xValue
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function set(string $sBag, string $sKey, $xValue): void
59
-    {
60
-        $this->bTouched = true;
61
-        $this->aData[$sBag][$sKey] = $xValue;
62
-    }
58
+public function set(string $sBag, string $sKey, $xValue): void
59
+{
60
+$this->bTouched = true;
61
+$this->aData[$sBag][$sKey] = $xValue;
62
+}
63 63
 
64
-    /**
64
+/**
65 65
      * @param string $sBag
66 66
      * @param string $sKey
67 67
      * @param mixed $xValue
68 68
      *
69 69
      * @return void
70 70
      */
71
-    public function new(string $sBag, string $sKey, $xValue): void
72
-    {
73
-        // Set the value only if it doesn't already exist.
74
-        if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
75
-        {
76
-            $this->set($sBag, $sKey, $xValue);
77
-        }
78
-    }
71
+public function new(string $sBag, string $sKey, $xValue): void
72
+{
73
+// Set the value only if it doesn't already exist.
74
+if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
75
+{
76
+$this->set($sBag, $sKey, $xValue);
77
+}
78
+}
79 79
 
80
-    /**
80
+/**
81 81
      * @param string $sBag
82 82
      * @param string $sKey
83 83
      * @param mixed $xValue
84 84
      *
85 85
      * @return mixed
86 86
      */
87
-    public function get(string $sBag, string $sKey, $xValue = null): mixed
88
-    {
89
-        return $this->aData[$sBag][$sKey] ?? $xValue;
90
-    }
87
+public function get(string $sBag, string $sKey, $xValue = null): mixed
88
+{
89
+return $this->aData[$sBag][$sKey] ?? $xValue;
90
+}
91 91
 
92
-    /**
92
+/**
93 93
      * Convert this call to array, when converting the response into json.
94 94
      *
95 95
      * @return array
96 96
      */
97
-    public function jsonSerialize(): array
98
-    {
99
-        return $this->aData;
100
-    }
97
+public function jsonSerialize(): array
98
+{
99
+return $this->aData;
100
+}
101 101
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Databag/DatabagPlugin.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
54 54
         // Todo: verify the checksums.
55 55
         $xData = ($this->fData)();
56 56
         $aData = is_string($xData) ?
57
-            (json_decode($xData, true) ?: []) :
58
-            (is_array($xData) ? $xData : []);
57
+            (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []);
59 58
         // Ensure all contents are arrays.
60 59
         return array_map(fn($aValue) => is_array($aValue) ? $aValue : [], $aData);
61 60
     }
@@ -83,7 +82,7 @@  discard block
 block discarded – undo
83 82
     public function writeCommand(): void
84 83
     {
85 84
         $xDatabag = $this->databag();
86
-        if($xDatabag->touched())
85
+        if ($xDatabag->touched())
87 86
         {
88 87
             // Todo: calculate the checksums.
89 88
             $this->addCommand('databag.set', ['values' => $xDatabag]);
Please login to merge, or discard this patch.