Passed
Push — main ( 87fed9...27211a )
by Thierry
04:04
created
jaxon-core/src/Di/Traits/DiAutoTrait.php 1 patch
Switch Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
 
25 25
 trait DiAutoTrait
26 26
 {
27
-    /**
27
+/**
28 28
      * The container for parameters
29 29
      *
30 30
      * @return Container
31 31
      */
32
-    abstract protected function cn(): Container;
32
+abstract protected function cn(): Container;
33 33
 
34
-    /**
34
+/**
35 35
      * Create an instance of a class, getting the constructor parameters from the DI container
36 36
      *
37 37
      * @param class-string|ReflectionClass $xClass The class name or the reflection class
@@ -40,36 +40,36 @@  discard block
 block discarded – undo
40 40
      * @throws ReflectionException
41 41
      * @throws SetupException
42 42
      */
43
-    public function make(string|ReflectionClass $xClass): mixed
44
-    {
45
-        if(is_string($xClass))
46
-        {
47
-            // Create the reflection class instance
48
-            $xClass = new ReflectionClass($xClass);
49
-        }
50
-        // Use the Reflection class to get the parameters of the constructor
51
-        if(($constructor = $xClass->getConstructor()) === null)
52
-        {
53
-            return $xClass->newInstance();
54
-        }
43
+public function make(string|ReflectionClass $xClass): mixed
44
+{
45
+if(is_string($xClass))
46
+{
47
+// Create the reflection class instance
48
+$xClass = new ReflectionClass($xClass);
49
+}
50
+// Use the Reflection class to get the parameters of the constructor
51
+if(($constructor = $xClass->getConstructor()) === null)
52
+{
53
+return $xClass->newInstance();
54
+}
55 55
 
56
-        $aParameters = array_map(function($xParameter) use($xClass) {
57
-            return $this->cn()->getParameter($xClass, $xParameter);
58
-        }, $constructor->getParameters());
59
-        return $xClass->newInstanceArgs($aParameters);
60
-    }
56
+$aParameters = array_map(function($xParameter) use($xClass) {
57
+return $this->cn()->getParameter($xClass, $xParameter);
58
+}, $constructor->getParameters());
59
+return $xClass->newInstanceArgs($aParameters);
60
+}
61 61
 
62
-    /**
62
+/**
63 63
      * Create an instance of a class by automatically fetching the dependencies in the constructor.
64 64
      *
65 65
      * @param class-string $sClass    The class name
66 66
      *
67 67
      * @return void
68 68
      */
69
-    public function auto(string $sClass): void
70
-    {
71
-        $this->set($sClass, function() use ($sClass) {
72
-            return $this->make($sClass);
73
-        });
74
-    }
69
+public function auto(string $sClass): void
70
+{
71
+$this->set($sClass, function() use ($sClass) {
72
+return $this->make($sClass);
73
+});
74
+}
75 75
 }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/PluginTrait.php 1 patch
Switch Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -34,154 +34,154 @@  discard block
 block discarded – undo
34 34
 
35 35
 trait PluginTrait
36 36
 {
37
-    /**
37
+/**
38 38
      * Register the values into the container
39 39
      *
40 40
      * @return void
41 41
      */
42
-    private function registerPlugins(): void
43
-    {
44
-        // Plugin manager
45
-        $this->set(PluginManager::class, function($di) {
46
-            $xPluginManager = new PluginManager($di->g(Container::class),
47
-                $di->g(CodeGenerator::class), $di->g(Translator::class));
48
-            // Register the Jaxon request and response plugins
49
-            $xPluginManager->registerPlugins();
50
-            return $xPluginManager;
51
-        });
52
-        // Package manager
53
-        $this->set(PackageManager::class, function($di) {
54
-            return new PackageManager($di->g(Container::class), $di->g(Translator::class),
55
-                $di->g(PluginManager::class), $di->g(ConfigManager::class),
56
-                $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
57
-                $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
58
-        });
59
-        // Code Generation
60
-        $this->set(MinifierInterface::class, function() {
61
-            return new class extends FileMinifier implements MinifierInterface
62
-            {};
63
-        });
64
-        $this->set(AssetManager::class, function($di) {
65
-            return new AssetManager($di->g(ConfigManager::class),
66
-                $di->g(MinifierInterface::class));
67
-        });
68
-        $this->set(CodeGenerator::class, function($di) {
69
-            return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
70
-                $di->g(TemplateEngine::class));
71
-        });
72
-        $this->set(ConfigScriptGenerator::class, function($di) {
73
-            return new ConfigScriptGenerator($di->g(ParameterReader::class),
74
-                $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
75
-        });
76
-        $this->set(ReadyScriptGenerator::class, function($di) {
77
-            return new ReadyScriptGenerator();
78
-        });
79
-
80
-        // Script response plugin
81
-        $this->set(ScriptPlugin::class, function($di) {
82
-            return new ScriptPlugin($di->g(CallFactory::class));
83
-        });
84
-        // Databag response plugin
85
-        $this->set(DatabagPlugin::class, function($di) {
86
-            return new DatabagPlugin($di->g(Container::class));
87
-        });
88
-        // Dialog response plugin
89
-        $this->set(DialogPlugin::class, function($di) {
90
-            return new DialogPlugin($di->g(DialogCommand::class));
91
-        });
92
-        // Paginator response plugin
93
-        $this->set(PaginatorPlugin::class, function($di) {
94
-            return new PaginatorPlugin($di->g(RendererInterface::class));
95
-        });
96
-    }
97
-
98
-    /**
42
+private function registerPlugins(): void
43
+{
44
+// Plugin manager
45
+$this->set(PluginManager::class, function($di) {
46
+$xPluginManager = new PluginManager($di->g(Container::class),
47
+    $di->g(CodeGenerator::class), $di->g(Translator::class));
48
+// Register the Jaxon request and response plugins
49
+$xPluginManager->registerPlugins();
50
+return $xPluginManager;
51
+});
52
+// Package manager
53
+$this->set(PackageManager::class, function($di) {
54
+return new PackageManager($di->g(Container::class), $di->g(Translator::class),
55
+    $di->g(PluginManager::class), $di->g(ConfigManager::class),
56
+    $di->g(CodeGenerator::class), $di->g(ViewRenderer::class),
57
+    $di->g(CallbackManager::class), $di->g(ComponentRegistry::class));
58
+});
59
+// Code Generation
60
+$this->set(MinifierInterface::class, function() {
61
+return new class extends FileMinifier implements MinifierInterface
62
+{};
63
+});
64
+$this->set(AssetManager::class, function($di) {
65
+return new AssetManager($di->g(ConfigManager::class),
66
+    $di->g(MinifierInterface::class));
67
+});
68
+$this->set(CodeGenerator::class, function($di) {
69
+return new CodeGenerator(Jaxon::VERSION, $di->g(Container::class),
70
+    $di->g(TemplateEngine::class));
71
+});
72
+$this->set(ConfigScriptGenerator::class, function($di) {
73
+return new ConfigScriptGenerator($di->g(ParameterReader::class),
74
+    $di->g(TemplateEngine::class), $di->g(ConfigManager::class));
75
+});
76
+$this->set(ReadyScriptGenerator::class, function($di) {
77
+return new ReadyScriptGenerator();
78
+});
79
+
80
+// Script response plugin
81
+$this->set(ScriptPlugin::class, function($di) {
82
+return new ScriptPlugin($di->g(CallFactory::class));
83
+});
84
+// Databag response plugin
85
+$this->set(DatabagPlugin::class, function($di) {
86
+return new DatabagPlugin($di->g(Container::class));
87
+});
88
+// Dialog response plugin
89
+$this->set(DialogPlugin::class, function($di) {
90
+return new DialogPlugin($di->g(DialogCommand::class));
91
+});
92
+// Paginator response plugin
93
+$this->set(PaginatorPlugin::class, function($di) {
94
+return new PaginatorPlugin($di->g(RendererInterface::class));
95
+});
96
+}
97
+
98
+/**
99 99
      * Get the plugin manager
100 100
      *
101 101
      * @return PluginManager
102 102
      */
103
-    public function getPluginManager(): PluginManager
104
-    {
105
-        return $this->g(PluginManager::class);
106
-    }
103
+public function getPluginManager(): PluginManager
104
+{
105
+return $this->g(PluginManager::class);
106
+}
107 107
 
108
-    /**
108
+/**
109 109
      * Get the package manager
110 110
      *
111 111
      * @return PackageManager
112 112
      */
113
-    public function getPackageManager(): PackageManager
114
-    {
115
-        return $this->g(PackageManager::class);
116
-    }
113
+public function getPackageManager(): PackageManager
114
+{
115
+return $this->g(PackageManager::class);
116
+}
117 117
 
118
-    /**
118
+/**
119 119
      * Get the code generator
120 120
      *
121 121
      * @return CodeGenerator
122 122
      */
123
-    public function getCodeGenerator(): CodeGenerator
124
-    {
125
-        return $this->g(CodeGenerator::class);
126
-    }
123
+public function getCodeGenerator(): CodeGenerator
124
+{
125
+return $this->g(CodeGenerator::class);
126
+}
127 127
 
128
-    /**
128
+/**
129 129
      * Get the asset manager
130 130
      *
131 131
      * @return AssetManager
132 132
      */
133
-    public function getAssetManager(): AssetManager
134
-    {
135
-        return $this->g(AssetManager::class);
136
-    }
133
+public function getAssetManager(): AssetManager
134
+{
135
+return $this->g(AssetManager::class);
136
+}
137 137
 
138
-    /**
138
+/**
139 139
      * Get the jQuery plugin
140 140
      *
141 141
      * @return ScriptPlugin
142 142
      */
143
-    public function getScriptPlugin(): ScriptPlugin
144
-    {
145
-        return $this->g(ScriptPlugin::class);
146
-    }
143
+public function getScriptPlugin(): ScriptPlugin
144
+{
145
+return $this->g(ScriptPlugin::class);
146
+}
147 147
 
148
-    /**
148
+/**
149 149
      * Get the dialog plugin
150 150
      *
151 151
      * @return DialogPlugin
152 152
      */
153
-    public function getDialogPlugin(): DialogPlugin
154
-    {
155
-        return $this->g(DialogPlugin::class);
156
-    }
153
+public function getDialogPlugin(): DialogPlugin
154
+{
155
+return $this->g(DialogPlugin::class);
156
+}
157 157
 
158
-    /**
158
+/**
159 159
      * @param class-string $sClassName    The package class name
160 160
      *
161 161
      * @return string
162 162
      */
163
-    private function getPackageConfigKey(string $sClassName): string
164
-    {
165
-        return $sClassName . '_PackageConfig';
166
-    }
163
+private function getPackageConfigKey(string $sClassName): string
164
+{
165
+return $sClassName . '_PackageConfig';
166
+}
167 167
 
168
-    /**
168
+/**
169 169
      * @param class-string $sClassName    The package class name
170 170
      * @param-closure-this Package $cSetter
171 171
      *
172 172
      * @return void
173 173
      */
174
-    private function extendPackage(string $sClassName, Closure $cSetter): void
175
-    {
176
-        // Initialize the package instance.
177
-        $this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
178
-            // Allow the setter to access protected attributes.
179
-            call_user_func($cSetter->bindTo($xPackage, $xPackage));
180
-            return $xPackage;
181
-        });
182
-    }
183
-
184
-    /**
174
+private function extendPackage(string $sClassName, Closure $cSetter): void
175
+{
176
+// Initialize the package instance.
177
+$this->xLibContainer->extend($sClassName, function($xPackage) use($cSetter) {
178
+// Allow the setter to access protected attributes.
179
+call_user_func($cSetter->bindTo($xPackage, $xPackage));
180
+return $xPackage;
181
+});
182
+}
183
+
184
+/**
185 185
      * Register a package
186 186
      *
187 187
      * @param class-string $sClassName    The package class name
@@ -190,45 +190,45 @@  discard block
 block discarded – undo
190 190
      * @return void
191 191
      * @throws SetupException
192 192
      */
193
-    public function registerPackage(string $sClassName, array $aUserOptions): void
194
-    {
195
-        // Register the user class, but only if the user didn't already.
196
-        if(!$this->h($sClassName))
197
-        {
198
-            $this->set($sClassName, fn() => $this->make($sClassName));
199
-        }
200
-
201
-        // Save the package config in the container.
202
-        $sConfigKey = $this->getPackageConfigKey($sClassName);
203
-        $this->set($sConfigKey, function($di) use($aUserOptions) {
204
-            $xOptionsProvider = $aUserOptions['provider'] ?? null;
205
-            // The user can provide a callable that returns the package options.
206
-            if(is_callable($xOptionsProvider))
207
-            {
208
-                $aUserOptions = $xOptionsProvider($aUserOptions);
209
-            }
210
-            return $di->g(ConfigManager::class)->newConfig($aUserOptions);
211
-        });
212
-
213
-        // Initialize the package instance.
214
-        $di = $this;
215
-        $this->extendPackage($sClassName, function() use($di, $sConfigKey) {
216
-            // $this here refers to the Package instance.
217
-            $this->xPkgConfig = $di->g($sConfigKey);
218
-            $this->xRenderer = $di->g(ViewRenderer::class);
219
-            $this->init();
220
-        });
221
-    }
222
-
223
-    /**
193
+public function registerPackage(string $sClassName, array $aUserOptions): void
194
+{
195
+// Register the user class, but only if the user didn't already.
196
+if(!$this->h($sClassName))
197
+{
198
+$this->set($sClassName, fn() => $this->make($sClassName));
199
+}
200
+
201
+// Save the package config in the container.
202
+$sConfigKey = $this->getPackageConfigKey($sClassName);
203
+$this->set($sConfigKey, function($di) use($aUserOptions) {
204
+$xOptionsProvider = $aUserOptions['provider'] ?? null;
205
+// The user can provide a callable that returns the package options.
206
+if(is_callable($xOptionsProvider))
207
+{
208
+    $aUserOptions = $xOptionsProvider($aUserOptions);
209
+}
210
+return $di->g(ConfigManager::class)->newConfig($aUserOptions);
211
+});
212
+
213
+// Initialize the package instance.
214
+$di = $this;
215
+$this->extendPackage($sClassName, function() use($di, $sConfigKey) {
216
+// $this here refers to the Package instance.
217
+$this->xPkgConfig = $di->g($sConfigKey);
218
+$this->xRenderer = $di->g(ViewRenderer::class);
219
+$this->init();
220
+});
221
+}
222
+
223
+/**
224 224
      * Get the config of a package
225 225
      *
226 226
      * @param class-string $sClassName    The package class name
227 227
      *
228 228
      * @return Config
229 229
      */
230
-    public function getPackageConfig(string $sClassName): Config
231
-    {
232
-        return $this->g($this->getPackageConfigKey($sClassName));
233
-    }
230
+public function getPackageConfig(string $sClassName): Config
231
+{
232
+return $this->g($this->getPackageConfigKey($sClassName));
233
+}
234 234
 }
Please login to merge, or discard this patch.
jaxon-core/src/Di/ComponentContainer.php 1 patch
Switch Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -39,73 +39,73 @@  discard block
 block discarded – undo
39 39
 
40 40
 class ComponentContainer
41 41
 {
42
-    use Traits\DiAutoTrait;
43
-    use Traits\ComponentTrait;
42
+use Traits\DiAutoTrait;
43
+use Traits\ComponentTrait;
44 44
 
45
-    /**
45
+/**
46 46
      * The Dependency Injection Container for registered classes
47 47
      *
48 48
      * @var PimpleContainer
49 49
      */
50
-    private $xContainer;
50
+private $xContainer;
51 51
 
52
-    /**
52
+/**
53 53
      * This will be set only when getting the object targetted by the ajax request.
54 54
      *
55 55
      * @var Target
56 56
      */
57
-    private $xTarget = null;
57
+private $xTarget = null;
58 58
 
59
-    /**
59
+/**
60 60
      * The class constructor
61 61
      *
62 62
      * @param Container $di
63 63
      */
64
-    public function __construct(private Container $di)
65
-    {
66
-        $this->xContainer = new PimpleContainer();
67
-        $this->val(ComponentContainer::class, $this);
68
-
69
-        // Register the call factory for registered functions
70
-        $this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
71
-            new JxnCall($this->di->g(ConfigManager::class)
72
-                ->getOption('core.prefix.function', '')));
73
-
74
-        // Register the pagination component, but do not export to js.
75
-        $this->saveComponent(Pagination::class, [
76
-            'excluded' => true,
77
-            'separator' => '.',
78
-            // The namespace has the same name as the Component class.
79
-            'namespace' => Component::class,
80
-        ]);
81
-
82
-        $this->setComponentPublicMethods('node', NodeComponent::class);
83
-        $this->setComponentPublicMethods('func', FuncComponent::class);
84
-    }
64
+public function __construct(private Container $di)
65
+{
66
+$this->xContainer = new PimpleContainer();
67
+$this->val(ComponentContainer::class, $this);
68
+
69
+// Register the call factory for registered functions
70
+$this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
71
+new JxnCall($this->di->g(ConfigManager::class)
72
+    ->getOption('core.prefix.function', '')));
73
+
74
+// Register the pagination component, but do not export to js.
75
+$this->saveComponent(Pagination::class, [
76
+'excluded' => true,
77
+'separator' => '.',
78
+// The namespace has the same name as the Component class.
79
+'namespace' => Component::class,
80
+]);
81
+
82
+$this->setComponentPublicMethods('node', NodeComponent::class);
83
+$this->setComponentPublicMethods('func', FuncComponent::class);
84
+}
85 85
 
86
-    /**
86
+/**
87 87
      * The container for parameters
88 88
      *
89 89
      * @return Container
90 90
      */
91
-    protected function cn(): Container
92
-    {
93
-        return $this->di;
94
-    }
91
+protected function cn(): Container
92
+{
93
+return $this->di;
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * Check if a class is defined in the container
98 98
      *
99 99
      * @param class-string $sClass    The full class name
100 100
      *
101 101
      * @return bool
102 102
      */
103
-    public function has(string $sClass): bool
104
-    {
105
-        return $this->xContainer->offsetExists($sClass);
106
-    }
103
+public function has(string $sClass): bool
104
+{
105
+return $this->xContainer->offsetExists($sClass);
106
+}
107 107
 
108
-    /**
108
+/**
109 109
      * Save a closure in the container
110 110
      *
111 111
      * @param class-string $sClass    The full class name
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return void
115 115
      */
116
-    public function set(string $sClass, Closure $xClosure)
117
-    {
118
-        $this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
119
-    }
116
+public function set(string $sClass, Closure $xClosure)
117
+{
118
+$this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
119
+}
120 120
 
121
-    /**
121
+/**
122 122
      * Save a value in the container
123 123
      *
124 124
      * @param string|class-string $sKey    The key
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
      *
127 127
      * @return void
128 128
      */
129
-    public function val(string $sKey, $xValue)
130
-    {
131
-       $this->xContainer->offsetSet($sKey, $xValue);
132
-    }
129
+public function val(string $sKey, $xValue)
130
+{
131
+$this->xContainer->offsetSet($sKey, $xValue);
132
+}
133 133
 
134
-    /**
134
+/**
135 135
      * Get a class instance
136 136
      *
137 137
      * @template T
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return T
141 141
      */
142
-    public function get(string $sClass)
143
-    {
144
-        return $this->xContainer->offsetGet($sClass);
145
-    }
142
+public function get(string $sClass)
143
+{
144
+return $this->xContainer->offsetGet($sClass);
145
+}
146 146
 
147
-    /**
147
+/**
148 148
      * Get a component when one of its method needs to be called
149 149
      *
150 150
      * @template T
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
      *
154 154
      * @return T|null
155 155
      */
156
-    public function getTargetComponent(string $sClassName, Target $xTarget): mixed
157
-    {
158
-        // Set the target only when getting the object targetted by the ajax request.
159
-        $this->xTarget = $xTarget;
160
-        $xComponent = $this->get($sClassName);
161
-        $this->xTarget = null;
156
+public function getTargetComponent(string $sClassName, Target $xTarget): mixed
157
+{
158
+// Set the target only when getting the object targetted by the ajax request.
159
+$this->xTarget = $xTarget;
160
+$xComponent = $this->get($sClassName);
161
+$this->xTarget = null;
162 162
 
163
-        return $xComponent;
164
-    }
163
+return $xComponent;
164
+}
165 165
 
166
-    /**
166
+/**
167 167
      * Register a component and its options
168 168
      *
169 169
      * @param class-string $sClassName    The class name
@@ -171,40 +171,40 @@  discard block
 block discarded – undo
171 171
      *
172 172
      * @return void
173 173
      */
174
-    public function saveComponent(string $sClassName, array $aOptions): void
175
-    {
176
-        try
177
-        {
178
-            // Make sure the registered class exists
179
-            if(isset($aOptions['include']))
180
-            {
181
-                require_once $aOptions['include'];
182
-            }
183
-            $xReflectionClass = new ReflectionClass($sClassName);
184
-            // Check if the class is registrable
185
-            if(!$xReflectionClass->isInstantiable())
186
-            {
187
-                return;
188
-            }
189
-
190
-            $this->_saveClassOptions($sClassName, $aOptions);
191
-
192
-            $sClassKey = $this->getReflectionClassKey($sClassName);
193
-            $this->val($sClassKey, $xReflectionClass);
194
-            // Register the user class, but only if the user didn't already.
195
-            if(!$this->has($sClassName))
196
-            {
197
-                $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
198
-            }
199
-        }
200
-        catch(ReflectionException $e)
201
-        {
202
-            throw new SetupException($this->cn()->g(Translator::class)
203
-                ->trans('errors.class.invalid', ['name' => $sClassName]));
204
-        }
205
-    }
174
+public function saveComponent(string $sClassName, array $aOptions): void
175
+{
176
+try
177
+{
178
+// Make sure the registered class exists
179
+if(isset($aOptions['include']))
180
+{
181
+    require_once $aOptions['include'];
182
+}
183
+$xReflectionClass = new ReflectionClass($sClassName);
184
+// Check if the class is registrable
185
+if(!$xReflectionClass->isInstantiable())
186
+{
187
+    return;
188
+}
189
+
190
+$this->_saveClassOptions($sClassName, $aOptions);
206 191
 
207
-    /**
192
+$sClassKey = $this->getReflectionClassKey($sClassName);
193
+$this->val($sClassKey, $xReflectionClass);
194
+// Register the user class, but only if the user didn't already.
195
+if(!$this->has($sClassName))
196
+{
197
+    $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
198
+}
199
+}
200
+catch(ReflectionException $e)
201
+{
202
+throw new SetupException($this->cn()->g(Translator::class)
203
+    ->trans('errors.class.invalid', ['name' => $sClassName]));
204
+}
205
+}
206
+
207
+/**
208 208
      * Register a component
209 209
      *
210 210
      * @param string $sComponentId The component name
@@ -212,74 +212,74 @@  discard block
 block discarded – undo
212 212
      * @return string
213 213
      * @throws SetupException
214 214
      */
215
-    private function _registerComponent(string $sComponentId): string
216
-    {
217
-        // Replace all separators ('.' or '_') with antislashes, and trim the class name.
218
-        $sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
219
-
220
-        $sComponentObject = $this->getCallableObjectKey($sClassName);
221
-        // Prevent duplication. It's important not to use the class name here.
222
-        if($this->has($sComponentObject))
223
-        {
224
-            return $sClassName;
225
-        }
226
-
227
-        // Register the helper class
228
-        $this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
229
-            $xFactory = $this->di->getCallFactory();
230
-            return new ComponentHelper($this, $xFactory->rq($sClassName),
231
-                $xFactory, $this->di->getViewRenderer(),
232
-                $this->di->getLogger(), $this->di->getSessionManager(),
233
-                $this->di->getStash(), $this->di->getUploadHandler());
234
-        });
235
-
236
-        $this->discoverComponent($sClassName);
237
-
238
-        // Register the callable object
239
-        $this->set($sComponentObject, function() use($sComponentId, $sClassName) {
240
-            $aOptions = $this->_getClassOptions($sComponentId);
241
-            $xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
242
-            $xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
243
-            return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
244
-        });
245
-
246
-        // Initialize the user class instance
247
-        $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
248
-            if($xClassInstance instanceof AbstractComponent)
249
-            {
250
-                $xHelper = $this->get($this->getCallableHelperKey($sClassName));
251
-                $xHelper->xTarget = $this->xTarget;
252
-
253
-                // Call the protected "initComponent()" method of the Component class.
254
-                $cSetter = function($di, $xHelper) {
255
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
256
-                };
257
-                $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
258
-                call_user_func($cSetter, $this->di, $xHelper);
259
-            }
260
-
261
-            // Run the callbacks for class initialisation
262
-            $this->di->g(CallbackManager::class)->onInit($xClassInstance);
263
-
264
-            // Set attributes from the DI container.
265
-            // The class level DI options are set on any component.
266
-            // The method level DI options are set only on the targetted component.
267
-            /** @var CallableObject */
268
-            $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
269
-            $xCallableObject->setDiClassAttributes($xClassInstance);
270
-            if($this->xTarget !== null)
271
-            {
272
-                $sMethodName = $this->xTarget->getMethodName();
273
-                $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
274
-            }
275
-
276
-            return $xClassInstance;
277
-        });
278
-
279
-        return $sClassName;
280
-    }
215
+private function _registerComponent(string $sComponentId): string
216
+{
217
+// Replace all separators ('.' or '_') with antislashes, and trim the class name.
218
+$sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
219
+
220
+$sComponentObject = $this->getCallableObjectKey($sClassName);
221
+// Prevent duplication. It's important not to use the class name here.
222
+if($this->has($sComponentObject))
223
+{
224
+return $sClassName;
225
+}
226
+
227
+// Register the helper class
228
+$this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
229
+$xFactory = $this->di->getCallFactory();
230
+return new ComponentHelper($this, $xFactory->rq($sClassName),
231
+    $xFactory, $this->di->getViewRenderer(),
232
+    $this->di->getLogger(), $this->di->getSessionManager(),
233
+    $this->di->getStash(), $this->di->getUploadHandler());
234
+});
235
+
236
+$this->discoverComponent($sClassName);
237
+
238
+// Register the callable object
239
+$this->set($sComponentObject, function() use($sComponentId, $sClassName) {
240
+$aOptions = $this->_getClassOptions($sComponentId);
241
+$xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
242
+$xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
243
+return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
244
+});
245
+
246
+// Initialize the user class instance
247
+$this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
248
+if($xClassInstance instanceof AbstractComponent)
249
+{
250
+    $xHelper = $this->get($this->getCallableHelperKey($sClassName));
251
+    $xHelper->xTarget = $this->xTarget;
252
+
253
+    // Call the protected "initComponent()" method of the Component class.
254
+    $cSetter = function($di, $xHelper) {
255
+        $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
256
+    };
257
+    $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
258
+    call_user_func($cSetter, $this->di, $xHelper);
259
+}
260
+
261
+// Run the callbacks for class initialisation
262
+$this->di->g(CallbackManager::class)->onInit($xClassInstance);
263
+
264
+// Set attributes from the DI container.
265
+// The class level DI options are set on any component.
266
+// The method level DI options are set only on the targetted component.
267
+/** @var CallableObject */
268
+$xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
269
+$xCallableObject->setDiClassAttributes($xClassInstance);
270
+if($this->xTarget !== null)
271
+{
272
+    $sMethodName = $this->xTarget->getMethodName();
273
+    $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
274
+}
275
+
276
+return $xClassInstance;
277
+});
281 278
 
282
-    /**
279
+return $sClassName;
280
+}
281
+
282
+/**
283 283
      * Get the callable object for a given class
284 284
      * The callable object is registered if it is not already in the DI.
285 285
      *
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
      * @return CallableObject|null
289 289
      * @throws SetupException
290 290
      */
291
-    public function makeCallableObject(string $sComponentId): ?CallableObject
292
-    {
293
-        $sClassName = $this->_registerComponent($sComponentId);
294
-        return $this->get($this->getCallableObjectKey($sClassName));
295
-    }
291
+public function makeCallableObject(string $sComponentId): ?CallableObject
292
+{
293
+$sClassName = $this->_registerComponent($sComponentId);
294
+return $this->get($this->getCallableObjectKey($sClassName));
295
+}
296 296
 
297
-    /**
297
+/**
298 298
      * Get an instance of a component by name
299 299
      *
300 300
      * @template T
@@ -303,53 +303,53 @@  discard block
 block discarded – undo
303 303
      * @return T|null
304 304
      * @throws SetupException
305 305
      */
306
-    public function makeComponent(string $sClassName): mixed
307
-    {
308
-        $sComponentId = str_replace('\\', '.', $sClassName);
309
-        $sClassName = $this->_registerComponent($sComponentId);
310
-        return $this->get($sClassName);
311
-    }
306
+public function makeComponent(string $sClassName): mixed
307
+{
308
+$sComponentId = str_replace('\\', '.', $sClassName);
309
+$sClassName = $this->_registerComponent($sComponentId);
310
+return $this->get($sClassName);
311
+}
312 312
 
313
-    /**
313
+/**
314 314
      * Get a factory for a call to a registered function.
315 315
      *
316 316
      * @return JxnCall
317 317
      */
318
-    public function getFunctionRequestFactory(): JxnCall
319
-    {
320
-        return $this->get($this->getRequestFactoryKey(JxnCall::class));
321
-    }
318
+public function getFunctionRequestFactory(): JxnCall
319
+{
320
+return $this->get($this->getRequestFactoryKey(JxnCall::class));
321
+}
322 322
 
323
-    /**
323
+/**
324 324
      * Get a factory for a call to a registered component.
325 325
      *
326 326
      * @param class-string $sClassName
327 327
      *
328 328
      * @return JxnCall|null
329 329
      */
330
-    public function getComponentRequestFactory(string $sClassName): ?JxnCall
330
+public function getComponentRequestFactory(string $sClassName): ?JxnCall
331
+{
332
+$sClassName = trim($sClassName, " \t");
333
+if($sClassName === '')
334
+{
335
+return null;
336
+}
337
+
338
+$sFactoryKey = $this->getRequestFactoryKey($sClassName);
339
+if(!$this->has($sFactoryKey))
340
+{
341
+$this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
342
+    $sComponentId = str_replace('\\', '.', $sClassName);
343
+    if(!($xCallable = $this->makeCallableObject($sComponentId)))
331 344
     {
332
-        $sClassName = trim($sClassName, " \t");
333
-        if($sClassName === '')
334
-        {
335
-            return null;
336
-        }
337
-
338
-        $sFactoryKey = $this->getRequestFactoryKey($sClassName);
339
-        if(!$this->has($sFactoryKey))
340
-        {
341
-            $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
342
-                $sComponentId = str_replace('\\', '.', $sClassName);
343
-                if(!($xCallable = $this->makeCallableObject($sComponentId)))
344
-                {
345
-                    return null;
346
-                }
347
-
348
-                $xConfigManager = $this->di->g(ConfigManager::class);
349
-                $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
350
-                return new JxnClassCall($sPrefix . $xCallable->getJsName());
351
-            });
352
-        }
353
-        return $this->get($sFactoryKey);
345
+        return null;
354 346
     }
347
+
348
+    $xConfigManager = $this->di->g(ConfigManager::class);
349
+    $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
350
+    return new JxnClassCall($sPrefix . $xCallable->getJsName());
351
+});
352
+}
353
+return $this->get($sFactoryKey);
354
+}
355 355
 }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Container.php 1 patch
Switch Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -33,145 +33,145 @@  discard block
 block discarded – undo
33 33
 
34 34
 class Container
35 35
 {
36
-    use Traits\AppTrait;
37
-    use Traits\PsrTrait;
38
-    use Traits\RequestTrait;
39
-    use Traits\ResponseTrait;
40
-    use Traits\PluginTrait;
41
-    use Traits\CallableTrait;
42
-    use Traits\ViewTrait;
43
-    use Traits\UtilTrait;
44
-    use Traits\MetadataTrait;
45
-    use Traits\DiAutoTrait;
36
+use Traits\AppTrait;
37
+use Traits\PsrTrait;
38
+use Traits\RequestTrait;
39
+use Traits\ResponseTrait;
40
+use Traits\PluginTrait;
41
+use Traits\CallableTrait;
42
+use Traits\ViewTrait;
43
+use Traits\UtilTrait;
44
+use Traits\MetadataTrait;
45
+use Traits\DiAutoTrait;
46 46
 
47
-    /**
47
+/**
48 48
      * The library Dependency Injection Container
49 49
      *
50 50
      * @var PimpleContainer
51 51
      */
52
-    private $xLibContainer;
52
+private $xLibContainer;
53 53
 
54
-    /**
54
+/**
55 55
      * The application or framework Dependency Injection Container
56 56
      *
57 57
      * @var ContainerInterface
58 58
      */
59
-    private $xAppContainer = null;
59
+private $xAppContainer = null;
60 60
 
61
-    /**
61
+/**
62 62
      * The class constructor
63 63
      */
64
-    public function __construct()
65
-    {
66
-        $this->xLibContainer = new PimpleContainer();
64
+public function __construct()
65
+{
66
+$this->xLibContainer = new PimpleContainer();
67 67
 
68
-        $this->val(Container::class, $this);
68
+$this->val(Container::class, $this);
69 69
 
70
-        // Register the null logger by default
71
-        $this->setLogger(new NullLogger());
70
+// Register the null logger by default
71
+$this->setLogger(new NullLogger());
72 72
 
73
-        // Template directory
74
-        $sTemplateDir = realpath(__DIR__ . '/../../templates');
75
-        $this->val('jaxon.core.dir.template', $sTemplateDir);
73
+// Template directory
74
+$sTemplateDir = realpath(__DIR__ . '/../../templates');
75
+$this->val('jaxon.core.dir.template', $sTemplateDir);
76 76
 
77
-        // Translation directory
78
-        $sTranslationDir = realpath(__DIR__ . '/../../translations');
79
-        $this->val('jaxon.core.dir.translation', $sTranslationDir);
77
+// Translation directory
78
+$sTranslationDir = realpath(__DIR__ . '/../../translations');
79
+$this->val('jaxon.core.dir.translation', $sTranslationDir);
80 80
 
81
-        $this->registerAll();
82
-        $this->setEventHandlers();
83
-    }
81
+$this->registerAll();
82
+$this->setEventHandlers();
83
+}
84 84
 
85
-    /**
85
+/**
86 86
      * The container for parameters
87 87
      *
88 88
      * @return Container
89 89
      */
90
-    protected function cn(): Container
91
-    {
92
-        return $this;
93
-    }
90
+protected function cn(): Container
91
+{
92
+return $this;
93
+}
94 94
 
95
-    /**
95
+/**
96 96
      * Register the values into the container
97 97
      *
98 98
      * @return void
99 99
      */
100
-    private function registerAll()
101
-    {
102
-        $this->registerApp();
103
-        $this->registerPsr();
104
-        $this->registerRequests();
105
-        $this->registerResponses();
106
-        $this->registerPlugins();
107
-        $this->registerCallables();
108
-        $this->registerViews();
109
-        $this->registerUtils();
110
-        $this->registerMetadataReader();
111
-    }
100
+private function registerAll()
101
+{
102
+$this->registerApp();
103
+$this->registerPsr();
104
+$this->registerRequests();
105
+$this->registerResponses();
106
+$this->registerPlugins();
107
+$this->registerCallables();
108
+$this->registerViews();
109
+$this->registerUtils();
110
+$this->registerMetadataReader();
111
+}
112 112
 
113
-    /**
113
+/**
114 114
      * Set the logger
115 115
      *
116 116
      * @param LoggerInterface|Closure $xLogger
117 117
      *
118 118
      * @return void
119 119
      */
120
-    public function setLogger(LoggerInterface|Closure $xLogger)
121
-    {
122
-        is_a($xLogger, LoggerInterface::class) ?
123
-            $this->val(LoggerInterface::class, $xLogger) :
124
-            $this->set(LoggerInterface::class, $xLogger);
125
-    }
120
+public function setLogger(LoggerInterface|Closure $xLogger)
121
+{
122
+is_a($xLogger, LoggerInterface::class) ?
123
+$this->val(LoggerInterface::class, $xLogger) :
124
+$this->set(LoggerInterface::class, $xLogger);
125
+}
126 126
 
127
-    /**
127
+/**
128 128
      * Get the logger
129 129
      *
130 130
      * @return LoggerInterface
131 131
      */
132
-    public function getLogger(): LoggerInterface
133
-    {
134
-        return $this->get(LoggerInterface::class);
135
-    }
132
+public function getLogger(): LoggerInterface
133
+{
134
+return $this->get(LoggerInterface::class);
135
+}
136 136
 
137
-    /**
137
+/**
138 138
      * Set the container provided by the integrated framework
139 139
      *
140 140
      * @param ContainerInterface $xContainer    The container implementation
141 141
      *
142 142
      * @return void
143 143
      */
144
-    public function setContainer(ContainerInterface $xContainer)
145
-    {
146
-        $this->xAppContainer = $xContainer;
147
-    }
144
+public function setContainer(ContainerInterface $xContainer)
145
+{
146
+$this->xAppContainer = $xContainer;
147
+}
148 148
 
149
-    /**
149
+/**
150 150
      * Check if a class is defined in the container
151 151
      *
152 152
      * @param string $sClass    The full class name
153 153
      *
154 154
      * @return bool
155 155
      */
156
-    public function h(string $sClass): bool
157
-    {
158
-        return $this->xLibContainer->offsetExists($sClass);
159
-    }
156
+public function h(string $sClass): bool
157
+{
158
+return $this->xLibContainer->offsetExists($sClass);
159
+}
160 160
 
161
-    /**
161
+/**
162 162
      * Check if a class is defined in the container
163 163
      *
164 164
      * @param string $sClass    The full class name
165 165
      *
166 166
      * @return bool
167 167
      */
168
-    public function has(string $sClass): bool
169
-    {
170
-        return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
171
-            true : $this->xLibContainer->offsetExists($sClass);
172
-    }
168
+public function has(string $sClass): bool
169
+{
170
+return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
171
+true : $this->xLibContainer->offsetExists($sClass);
172
+}
173 173
 
174
-    /**
174
+/**
175 175
      * Get a class instance
176 176
      *
177 177
      * @template T
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
      *
180 180
      * @return T
181 181
      */
182
-    public function g(string $sClass): mixed
183
-    {
184
-        return $this->xLibContainer->offsetGet($sClass);
185
-    }
182
+public function g(string $sClass): mixed
183
+{
184
+return $this->xLibContainer->offsetGet($sClass);
185
+}
186 186
 
187
-    /**
187
+/**
188 188
      * Get a class instance
189 189
      *
190 190
      * @template T
@@ -193,24 +193,24 @@  discard block
 block discarded – undo
193 193
      * @return T
194 194
      * @throws SetupException
195 195
      */
196
-    public function get(string $sClass): mixed
197
-    {
198
-        try
199
-        {
200
-            return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
201
-                $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass);
202
-        }
203
-        catch(Exception|Throwable $e)
204
-        {
205
-            $xLogger = $this->g(LoggerInterface::class);
206
-            $xTranslator = $this->g(Translator::class);
207
-            $sMessage = $e->getMessage() . ': ' . $xTranslator->trans('errors.class.container', ['name' => $sClass]);
208
-            $xLogger->error($e->getMessage(), ['message' => $sMessage]);
209
-            throw new SetupException($sMessage);
210
-        }
211
-    }
196
+public function get(string $sClass): mixed
197
+{
198
+try
199
+{
200
+return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
201
+    $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass);
202
+}
203
+catch(Exception|Throwable $e)
204
+{
205
+$xLogger = $this->g(LoggerInterface::class);
206
+$xTranslator = $this->g(Translator::class);
207
+$sMessage = $e->getMessage() . ': ' . $xTranslator->trans('errors.class.container', ['name' => $sClass]);
208
+$xLogger->error($e->getMessage(), ['message' => $sMessage]);
209
+throw new SetupException($sMessage);
210
+}
211
+}
212 212
 
213
-    /**
213
+/**
214 214
      * Save a closure in the container
215 215
      *
216 216
      * @param string|class-string $sClass    The full class name
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * @return void
221 221
      */
222
-    public function set(string $sClass, Closure $xClosure, bool $bIsSingleton = true)
223
-    {
224
-        // Wrap the user closure into a new closure, so it can take this container as a parameter.
225
-        $xClosure = fn() => $xClosure($this);
226
-        $this->xLibContainer->offsetSet($sClass, $bIsSingleton ?
227
-            $xClosure : $this->xLibContainer->factory($xClosure));
228
-    }
222
+public function set(string $sClass, Closure $xClosure, bool $bIsSingleton = true)
223
+{
224
+// Wrap the user closure into a new closure, so it can take this container as a parameter.
225
+$xClosure = fn() => $xClosure($this);
226
+$this->xLibContainer->offsetSet($sClass, $bIsSingleton ?
227
+$xClosure : $this->xLibContainer->factory($xClosure));
228
+}
229 229
 
230
-    /**
230
+/**
231 231
      * Save a value in the container
232 232
      *
233 233
      * @param string|class-string $sKey    The key
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
      *
236 236
      * @return void
237 237
      */
238
-    public function val(string $sKey, $xValue)
239
-    {
240
-       $this->xLibContainer->offsetSet($sKey, $xValue);
241
-    }
238
+public function val(string $sKey, $xValue)
239
+{
240
+$this->xLibContainer->offsetSet($sKey, $xValue);
241
+}
242 242
 
243
-    /**
243
+/**
244 244
      * Set an alias in the container
245 245
      *
246 246
      * @param string|class-string $sAlias    The alias name
@@ -248,60 +248,60 @@  discard block
 block discarded – undo
248 248
      *
249 249
      * @return void
250 250
      */
251
-    public function alias(string $sAlias, string $sClass)
252
-    {
253
-        $this->set($sAlias, function($di) use ($sClass) {
254
-            return $di->get($sClass);
255
-        });
256
-    }
251
+public function alias(string $sAlias, string $sClass)
252
+{
253
+$this->set($sAlias, function($di) use ($sClass) {
254
+return $di->get($sClass);
255
+});
256
+}
257 257
 
258
-    /**
258
+/**
259 259
      * @param ReflectionClass $xClass
260 260
      * @param ReflectionParameter $xParameter
261 261
      *
262 262
      * @return mixed
263 263
      * @throws SetupException
264 264
      */
265
-    public function getParameter(ReflectionClass $xClass, ReflectionParameter $xParameter)
266
-    {
267
-        $xType = $xParameter->getType();
268
-        // Check the parameter class first.
269
-        if($xType instanceof ReflectionNamedType)
270
-        {
271
-            // Check the class + the name
272
-            if($this->has($xType->getName() . ' $' . $xParameter->getName()))
273
-            {
274
-                return $this->get($xType->getName() . ' $' . $xParameter->getName());
275
-            }
276
-            // Check the class only
277
-            if($this->has($xType->getName()))
278
-            {
279
-                return $this->get($xType->getName());
280
-            }
281
-        }
282
-        // Check the name only
283
-        return $this->get('$' . $xParameter->getName());
284
-    }
265
+public function getParameter(ReflectionClass $xClass, ReflectionParameter $xParameter)
266
+{
267
+$xType = $xParameter->getType();
268
+// Check the parameter class first.
269
+if($xType instanceof ReflectionNamedType)
270
+{
271
+// Check the class + the name
272
+if($this->has($xType->getName() . ' $' . $xParameter->getName()))
273
+{
274
+    return $this->get($xType->getName() . ' $' . $xParameter->getName());
275
+}
276
+// Check the class only
277
+if($this->has($xType->getName()))
278
+{
279
+    return $this->get($xType->getName());
280
+}
281
+}
282
+// Check the name only
283
+return $this->get('$' . $xParameter->getName());
284
+}
285 285
 
286
-    /**
286
+/**
287 287
      * Get the session manager
288 288
      *
289 289
      * @return SessionInterface|null
290 290
      */
291
-    public function getSessionManager(): ?SessionInterface
292
-    {
293
-        return $this->h(SessionInterface::class) ? $this->g(SessionInterface::class) : null;
294
-    }
291
+public function getSessionManager(): ?SessionInterface
292
+{
293
+return $this->h(SessionInterface::class) ? $this->g(SessionInterface::class) : null;
294
+}
295 295
 
296
-    /**
296
+/**
297 297
      * Set the session manager
298 298
      *
299 299
      * @param Closure $xClosure    A closure to create the session manager instance
300 300
      *
301 301
      * @return void
302 302
      */
303
-    public function setSessionManager(Closure $xClosure)
304
-    {
305
-        $this->set(SessionInterface::class, $xClosure);
306
-    }
303
+public function setSessionManager(Closure $xClosure)
304
+{
305
+$this->set(SessionInterface::class, $xClosure);
306
+}
307 307
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/Paginator.php 1 patch
Switch Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -59,52 +59,52 @@  discard block
 block discarded – undo
59 59
 
60 60
 class Paginator
61 61
 {
62
-    /**
62
+/**
63 63
      * @var integer
64 64
      */
65
-    protected $nItemsCount = 0;
65
+protected $nItemsCount = 0;
66 66
 
67
-    /**
67
+/**
68 68
      * @var integer
69 69
      */
70
-    protected $nPagesCount = 0;
70
+protected $nPagesCount = 0;
71 71
 
72
-    /**
72
+/**
73 73
      * @var integer
74 74
      */
75
-    protected $nItemsPerPage = 0;
75
+protected $nItemsPerPage = 0;
76 76
 
77
-    /**
77
+/**
78 78
      * @var integer
79 79
      */
80
-    protected $nPageNumber = 0;
80
+protected $nPageNumber = 0;
81 81
 
82
-    /**
82
+/**
83 83
      * @var integer
84 84
      */
85
-    protected $nMaxPages = 10;
85
+protected $nMaxPages = 10;
86 86
 
87
-    /**
87
+/**
88 88
      * @var string
89 89
      */
90
-    protected $sPreviousText = '«';
90
+protected $sPreviousText = '«';
91 91
 
92
-    /**
92
+/**
93 93
      * @var string
94 94
      */
95
-    protected $sNextText = '»';
95
+protected $sNextText = '»';
96 96
 
97
-    /**
97
+/**
98 98
      * @var string
99 99
      */
100
-    protected $sEllipsysText = '...';
100
+protected $sEllipsysText = '...';
101 101
 
102
-    /**
102
+/**
103 103
      * @var PaginatorPlugin
104 104
      */
105
-    private $xPlugin;
105
+private $xPlugin;
106 106
 
107
-    /**
107
+/**
108 108
      * The constructor.
109 109
      *
110 110
      * @param PaginatorPlugin $xPlugin
@@ -112,293 +112,293 @@  discard block
 block discarded – undo
112 112
      * @param int $nItemsPerPage    The number of items per page
113 113
      * @param int $nItemsCount      The total number of items
114 114
      */
115
-    public function __construct(PaginatorPlugin $xPlugin, int $nPageNumber, int $nItemsPerPage, int $nItemsCount)
116
-    {
117
-        $this->xPlugin = $xPlugin;
118
-        $this->nItemsPerPage = $nItemsPerPage > 0 ? $nItemsPerPage : 0;
119
-        $this->nItemsCount = $nItemsCount > 0 ? $nItemsCount : 0;
120
-        $this->nPageNumber = $nPageNumber < 1 ? 1 : $nPageNumber;
121
-        $this->updatePagesCount();
122
-    }
123
-
124
-    /**
115
+public function __construct(PaginatorPlugin $xPlugin, int $nPageNumber, int $nItemsPerPage, int $nItemsCount)
116
+{
117
+$this->xPlugin = $xPlugin;
118
+$this->nItemsPerPage = $nItemsPerPage > 0 ? $nItemsPerPage : 0;
119
+$this->nItemsCount = $nItemsCount > 0 ? $nItemsCount : 0;
120
+$this->nPageNumber = $nPageNumber < 1 ? 1 : $nPageNumber;
121
+$this->updatePagesCount();
122
+}
123
+
124
+/**
125 125
      * Update the number of pages
126 126
      *
127 127
      * @return Paginator
128 128
      */
129
-    private function updatePagesCount(): Paginator
130
-    {
131
-        $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 :
132
-            (int)ceil($this->nItemsCount / $this->nItemsPerPage));
133
-        if($this->nPageNumber > $this->nPagesCount)
134
-        {
135
-            $this->nPageNumber = $this->nPagesCount;
136
-        }
137
-        return $this;
138
-    }
139
-
140
-    /**
129
+private function updatePagesCount(): Paginator
130
+{
131
+$this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 :
132
+(int)ceil($this->nItemsCount / $this->nItemsPerPage));
133
+if($this->nPageNumber > $this->nPagesCount)
134
+{
135
+$this->nPageNumber = $this->nPagesCount;
136
+}
137
+return $this;
138
+}
139
+
140
+/**
141 141
      * Set the text for the previous page link
142 142
      *
143 143
      * @param string $sText    The text for the previous page link
144 144
      *
145 145
      * @return Paginator
146 146
      */
147
-    public function setPreviousText(string $sText): Paginator
148
-    {
149
-        $this->sPreviousText = $sText;
150
-        return $this;
151
-    }
147
+public function setPreviousText(string $sText): Paginator
148
+{
149
+$this->sPreviousText = $sText;
150
+return $this;
151
+}
152 152
 
153
-    /**
153
+/**
154 154
      * Set the text for the next page link
155 155
      *
156 156
      * @param string $sText    The text for the previous page link
157 157
      *
158 158
      * @return Paginator
159 159
      */
160
-    public function setNextText(string $sText): Paginator
161
-    {
162
-        $this->sNextText = $sText;
163
-        return $this;
164
-    }
160
+public function setNextText(string $sText): Paginator
161
+{
162
+$this->sNextText = $sText;
163
+return $this;
164
+}
165 165
 
166
-    /**
166
+/**
167 167
      * Set the max number of pages to show
168 168
      *
169 169
      * @param int $nMaxPages    The max number of pages to show
170 170
      *
171 171
      * @return Paginator
172 172
      */
173
-    public function setMaxPages(int $nMaxPages): Paginator
174
-    {
175
-        $this->nMaxPages = max($nMaxPages, 4);
176
-        return $this;
177
-    }
173
+public function setMaxPages(int $nMaxPages): Paginator
174
+{
175
+$this->nMaxPages = max($nMaxPages, 4);
176
+return $this;
177
+}
178 178
 
179
-    /**
179
+/**
180 180
      * Get the previous page data.
181 181
      *
182 182
      * @return Page
183 183
      */
184
-    protected function getPrevPage(): Page
185
-    {
186
-        return $this->nPageNumber <= 1 ?
187
-            new Page('disabled', $this->sPreviousText, 0) :
188
-            new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1);
189
-    }
190
-
191
-    /**
184
+protected function getPrevPage(): Page
185
+{
186
+return $this->nPageNumber <= 1 ?
187
+new Page('disabled', $this->sPreviousText, 0) :
188
+new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1);
189
+}
190
+
191
+/**
192 192
      * Get the next page data.
193 193
      *
194 194
      * @return Page
195 195
      */
196
-    protected function getNextPage(): Page
197
-    {
198
-        return $this->nPageNumber >= $this->nPagesCount ?
199
-            new Page('disabled', $this->sNextText, 0) :
200
-            new Page('enabled', $this->sNextText, $this->nPageNumber + 1);
201
-    }
202
-
203
-    /**
196
+protected function getNextPage(): Page
197
+{
198
+return $this->nPageNumber >= $this->nPagesCount ?
199
+new Page('disabled', $this->sNextText, 0) :
200
+new Page('enabled', $this->sNextText, $this->nPageNumber + 1);
201
+}
202
+
203
+/**
204 204
      * Get a page data.
205 205
      *
206 206
      * @param integer $nNumber    The page number
207 207
      *
208 208
      * @return Page
209 209
      */
210
-    protected function getPage(int $nNumber): Page
211
-    {
212
-        if($nNumber < 1)
213
-        {
214
-            return new Page('disabled', $this->sEllipsysText, 0);
215
-        }
216
-        $sType = ($nNumber === $this->nPageNumber ? 'current' : 'enabled');
217
-        return new Page($sType, "$nNumber", $nNumber);
218
-    }
219
-
220
-    /**
210
+protected function getPage(int $nNumber): Page
211
+{
212
+if($nNumber < 1)
213
+{
214
+return new Page('disabled', $this->sEllipsysText, 0);
215
+}
216
+$sType = ($nNumber === $this->nPageNumber ? 'current' : 'enabled');
217
+return new Page($sType, "$nNumber", $nNumber);
218
+}
219
+
220
+/**
221 221
      * Get the array of page numbers to be printed.
222 222
      *
223 223
      * Example: [1, 0, 4, 5, 6, 0, 10]
224 224
      *
225 225
      * @return array
226 226
      */
227
-    protected function getPageNumbers(): array
228
-    {
229
-        $aPageNumbers = [];
230
-
231
-        if($this->nPagesCount <= $this->nMaxPages)
232
-        {
233
-            for($i = 0; $i < $this->nPagesCount; $i++)
234
-            {
235
-                $aPageNumbers[] = $i + 1;
236
-            }
237
-
238
-            return $aPageNumbers;
239
-        }
240
-
241
-        // Determine the sliding range, centered around the current page.
242
-        $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2);
243
-
244
-        $nSlidingStart = 1;
245
-        $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber;
246
-        if($nSlidingEndOffset < 0)
247
-        {
248
-            $nSlidingStart = $this->nPageNumber - $nNumAdjacents;
249
-            $nSlidingEndOffset = 0;
250
-        }
251
-
252
-        $nSlidingEnd = $this->nPagesCount;
253
-        $nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount;
254
-        if($nSlidingStartOffset < 0)
255
-        {
256
-            $nSlidingEnd = $this->nPageNumber + $nNumAdjacents;
257
-            $nSlidingStartOffset = 0;
258
-        }
259
-
260
-        // Build the list of page numbers.
261
-        if($nSlidingStart > 1)
262
-        {
263
-            $aPageNumbers[] = 1;
264
-            $aPageNumbers[] = 0; // Ellipsys;
265
-        }
266
-        for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++)
267
-        {
268
-            $aPageNumbers[] = $i;
269
-        }
270
-        if($nSlidingEnd < $this->nPagesCount)
271
-        {
272
-            $aPageNumbers[] = 0; // Ellipsys;
273
-            $aPageNumbers[] = $this->nPagesCount;
274
-        }
275
-
276
-        return $aPageNumbers;
277
-    }
278
-
279
-    /**
227
+protected function getPageNumbers(): array
228
+{
229
+$aPageNumbers = [];
230
+
231
+if($this->nPagesCount <= $this->nMaxPages)
232
+{
233
+for($i = 0; $i < $this->nPagesCount; $i++)
234
+{
235
+    $aPageNumbers[] = $i + 1;
236
+}
237
+
238
+return $aPageNumbers;
239
+}
240
+
241
+// Determine the sliding range, centered around the current page.
242
+$nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2);
243
+
244
+$nSlidingStart = 1;
245
+$nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber;
246
+if($nSlidingEndOffset < 0)
247
+{
248
+$nSlidingStart = $this->nPageNumber - $nNumAdjacents;
249
+$nSlidingEndOffset = 0;
250
+}
251
+
252
+$nSlidingEnd = $this->nPagesCount;
253
+$nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount;
254
+if($nSlidingStartOffset < 0)
255
+{
256
+$nSlidingEnd = $this->nPageNumber + $nNumAdjacents;
257
+$nSlidingStartOffset = 0;
258
+}
259
+
260
+// Build the list of page numbers.
261
+if($nSlidingStart > 1)
262
+{
263
+$aPageNumbers[] = 1;
264
+$aPageNumbers[] = 0; // Ellipsys;
265
+}
266
+for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++)
267
+{
268
+$aPageNumbers[] = $i;
269
+}
270
+if($nSlidingEnd < $this->nPagesCount)
271
+{
272
+$aPageNumbers[] = 0; // Ellipsys;
273
+$aPageNumbers[] = $this->nPagesCount;
274
+}
275
+
276
+return $aPageNumbers;
277
+}
278
+
279
+/**
280 280
      * Get the current page number.
281 281
      *
282 282
      * @return int
283 283
      */
284
-    public function currentPage(): int
285
-    {
286
-        return $this->nPageNumber;
287
-    }
284
+public function currentPage(): int
285
+{
286
+return $this->nPageNumber;
287
+}
288 288
 
289
-    /**
289
+/**
290 290
      * Get the links (pages raw data).
291 291
      *
292 292
      * @return array<Page>
293 293
      */
294
-    public function pages(): array
295
-    {
296
-        if($this->nPagesCount < 2)
297
-        {
298
-            return [];
299
-        }
300
-
301
-        $aPageNumbers = $this->getPageNumbers();
302
-        $aPages = [$this->getPrevPage()];
303
-        array_walk($aPageNumbers, function($nNumber) use(&$aPages) {
304
-            $aPages[] = $this->getPage($nNumber);
305
-        });
306
-        $aPages[] = $this->getNextPage();
307
-
308
-        return $aPages;
309
-    }
310
-
311
-    /**
294
+public function pages(): array
295
+{
296
+if($this->nPagesCount < 2)
297
+{
298
+return [];
299
+}
300
+
301
+$aPageNumbers = $this->getPageNumbers();
302
+$aPages = [$this->getPrevPage()];
303
+array_walk($aPageNumbers, function($nNumber) use(&$aPages) {
304
+$aPages[] = $this->getPage($nNumber);
305
+});
306
+$aPages[] = $this->getNextPage();
307
+
308
+return $aPages;
309
+}
310
+
311
+/**
312 312
      * Call a closure that will receive the page number as parameter.
313 313
      *
314 314
      * @param Closure $fPageCallback
315 315
      *
316 316
      * @return Paginator
317 317
      */
318
-    public function page(Closure $fPageCallback): Paginator
319
-    {
320
-        $fPageCallback($this->nPageNumber);
318
+public function page(Closure $fPageCallback): Paginator
319
+{
320
+$fPageCallback($this->nPageNumber);
321 321
 
322
-        return $this;
323
-    }
322
+return $this;
323
+}
324 324
 
325
-    /**
325
+/**
326 326
      * Call a closure that will receive the pagination offset as parameter.
327 327
      *
328 328
      * @param Closure $fOffsetCallback
329 329
      *
330 330
      * @return Paginator
331 331
      */
332
-    public function offset(Closure $fOffsetCallback): Paginator
333
-    {
334
-        $fOffsetCallback(($this->nPageNumber - 1) * $this->nItemsPerPage);
332
+public function offset(Closure $fOffsetCallback): Paginator
333
+{
334
+$fOffsetCallback(($this->nPageNumber - 1) * $this->nItemsPerPage);
335 335
 
336
-        return $this;
337
-    }
336
+return $this;
337
+}
338 338
 
339
-    /**
339
+/**
340 340
      * Show the pagination links
341 341
      *
342 342
      * @return string
343 343
      */
344
-    private function renderLinks(): string
345
-    {
346
-        $aPages = $this->pages();
347
-        if(count($aPages) === 0)
348
-        {
349
-            return '';
350
-        }
351
-
352
-        $xPrevPage = array_shift($aPages); // The first entry in the array
353
-        $xNextPage = array_pop($aPages); // The last entry in the array
354
-        return $this->xPlugin->renderer()->render($aPages, $xPrevPage, $xNextPage);
355
-    }
356
-
357
-    /**
344
+private function renderLinks(): string
345
+{
346
+$aPages = $this->pages();
347
+if(count($aPages) === 0)
348
+{
349
+return '';
350
+}
351
+
352
+$xPrevPage = array_shift($aPages); // The first entry in the array
353
+$xNextPage = array_pop($aPages); // The last entry in the array
354
+return $this->xPlugin->renderer()->render($aPages, $xPrevPage, $xNextPage);
355
+}
356
+
357
+/**
358 358
      * Show the pagination links
359 359
      *
360 360
      * @param string $sWrapperId
361 361
      *
362 362
      * @return array|null
363 363
      */
364
-    private function showLinks(string $sWrapperId): ?array
365
-    {
366
-        $sHtml = $this->renderLinks();
367
-        // The HTML code must always be displayed, even if it is empty.
368
-        if(is_a($this->xPlugin->response(), Response::class))
369
-        {
370
-            /** @var Response */
371
-            $xResponse = $this->xPlugin->response();
372
-            $xResponse->html($sWrapperId, $sHtml);
373
-            return !$sHtml ? null : ['id' => $sWrapperId];
374
-        }
375
-
376
-        // The wrapper id is not needed for the NodeResponse
377
-        /** @var NodeResponse */
378
-        $xResponse = $this->xPlugin->response();
379
-        $xResponse->html($sHtml);
380
-        return !$sHtml ? null : [];
381
-    }
382
-
383
-    /**
364
+private function showLinks(string $sWrapperId): ?array
365
+{
366
+$sHtml = $this->renderLinks();
367
+// The HTML code must always be displayed, even if it is empty.
368
+if(is_a($this->xPlugin->response(), Response::class))
369
+{
370
+/** @var Response */
371
+$xResponse = $this->xPlugin->response();
372
+$xResponse->html($sWrapperId, $sHtml);
373
+return !$sHtml ? null : ['id' => $sWrapperId];
374
+}
375
+
376
+// The wrapper id is not needed for the NodeResponse
377
+/** @var NodeResponse */
378
+$xResponse = $this->xPlugin->response();
379
+$xResponse->html($sHtml);
380
+return !$sHtml ? null : [];
381
+}
382
+
383
+/**
384 384
      * @param JsExpr $xCall
385 385
      * @param string $sWrapperId
386 386
      *
387 387
      * @return void
388 388
      */
389
-    public function render(JsExpr $xCall, string $sWrapperId = ''): void
390
-    {
391
-        if(($xFunc = $xCall->func()) === null)
392
-        {
393
-            return;
394
-        }
395
-
396
-        $aParams = $this->showLinks(trim($sWrapperId));
397
-        if($aParams !== null)
398
-        {
399
-            // Set click handlers on the pagination links
400
-            $aParams['func'] = $xFunc->withPage()->jsonSerialize();
401
-            $this->xPlugin->addCommand('pg.paginate', $aParams);
402
-        }
403
-    }
389
+public function render(JsExpr $xCall, string $sWrapperId = ''): void
390
+{
391
+if(($xFunc = $xCall->func()) === null)
392
+{
393
+return;
394
+}
395
+
396
+$aParams = $this->showLinks(trim($sWrapperId));
397
+if($aParams !== null)
398
+{
399
+// Set click handlers on the pagination links
400
+$aParams['func'] = $xFunc->withPage()->jsonSerialize();
401
+$this->xPlugin->addCommand('pg.paginate', $aParams);
402
+}
403
+}
404 404
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/RendererInterface.php 1 patch
Switch Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 interface RendererInterface
18 18
 {
19
-    /**
19
+/**
20 20
      * Render an array of pagination links
21 21
      *
22 22
      * @param Page[] $aPages
@@ -25,5 +25,5 @@  discard block
 block discarded – undo
25 25
      *
26 26
      * @return string
27 27
      */
28
-    public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string;
28
+public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string;
29 29
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/Renderer.php 1 patch
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
 
22 22
 class Renderer implements RendererInterface
23 23
 {
24
-    /**
24
+/**
25 25
      * The constructor.
26 26
      *
27 27
      * @param ViewRenderer $xRenderer
28 28
      */
29
-    public function __construct(private ViewRenderer $xRenderer)
30
-    {
31
-        $this->xRenderer = $xRenderer;
32
-    }
29
+public function __construct(private ViewRenderer $xRenderer)
30
+{
31
+$this->xRenderer = $xRenderer;
32
+}
33 33
 
34
-    /**
34
+/**
35 35
      * @param Page $xPage
36 36
      *
37 37
      * @return string
38 38
      */
39
-    private function renderPage(Page $xPage): string
40
-    {
41
-        return $this->xRenderer->render("pagination::links/{$xPage->sType}", [
42
-            'page' => $xPage->nNumber,
43
-            'text' => $xPage->sText,
44
-        ])->__toString();
45
-    }
39
+private function renderPage(Page $xPage): string
40
+{
41
+return $this->xRenderer->render("pagination::links/{$xPage->sType}", [
42
+'page' => $xPage->nNumber,
43
+'text' => $xPage->sText,
44
+])->__toString();
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * Render an array of pagination links
49 49
      *
50 50
      * @param Page[] $aPages
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return string
55 55
      */
56
-    public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string
57
-    {
58
-        return trim($this->xRenderer->render('pagination::wrapper', [
59
-            'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages),
60
-            'prev' => $this->renderPage($xPrevPage),
61
-            'next' => $this->renderPage($xNextPage),
62
-        ])->__toString());
63
-    }
56
+public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string
57
+{
58
+return trim($this->xRenderer->render('pagination::wrapper', [
59
+'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages),
60
+'prev' => $this->renderPage($xPrevPage),
61
+'next' => $this->renderPage($xNextPage),
62
+])->__toString());
63
+}
64 64
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/Page.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 
14 14
 class Page
15 15
 {
16
-    /**
16
+/**
17 17
      * @var string
18 18
      */
19
-    public $sType;
19
+public $sType;
20 20
 
21
-    /**
21
+/**
22 22
      * @var string
23 23
      */
24
-    public $sText;
24
+public $sText;
25 25
 
26
-    /**
26
+/**
27 27
      * @var string
28 28
      */
29
-    public $nNumber;
29
+public $nNumber;
30 30
 
31
-    public function __construct(string $sType, string $sText, int $nNumber)
32
-    {
33
-        $this->sType = $sType;
34
-        $this->sText = $sText;
35
-        $this->nNumber = $nNumber;
36
-    }
31
+public function __construct(string $sType, string $sText, int $nNumber)
32
+{
33
+$this->sType = $sType;
34
+$this->sText = $sText;
35
+$this->nNumber = $nNumber;
36
+}
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
jaxon-core/src/App/NodeComponent.php 1 patch
Switch Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
 
9 9
 abstract class NodeComponent extends Component\AbstractComponent
10 10
 {
11
-    use Component\HelperTrait;
12
-    use Component\NodeResponseTrait;
13
-    use Component\AjaxResponseTrait;
14
-    use Component\ComponentTrait;
11
+use Component\HelperTrait;
12
+use Component\NodeResponseTrait;
13
+use Component\AjaxResponseTrait;
14
+use Component\ComponentTrait;
15 15
 
16
-    /**
16
+/**
17 17
      * @inheritDoc
18 18
      */
19
-    final protected function initComponent(Container $di, ComponentHelper $xHelper): void
20
-    {
21
-        $this->setHelper($xHelper);
22
-        $this->setNodeResponse($di);
23
-        $this->setAjaxResponse($di);
24
-    }
19
+final protected function initComponent(Container $di, ComponentHelper $xHelper): void
20
+{
21
+$this->setHelper($xHelper);
22
+$this->setNodeResponse($di);
23
+$this->setAjaxResponse($di);
24
+}
25 25
 
26
-    /**
26
+/**
27 27
      * @return string|Stringable
28 28
      */
29
-    abstract public function html(): string|Stringable;
29
+abstract public function html(): string|Stringable;
30 30
 
31
-    /**
31
+/**
32 32
      * Called before rendering the component.
33 33
      *
34 34
      * @return void
35 35
      */
36
-    protected function before(): void
37
-    {}
36
+protected function before(): void
37
+{}
38 38
 
39
-    /**
39
+/**
40 40
      * Called after rendering the component.
41 41
      *
42 42
      * @return void
43 43
      */
44
-    protected function after(): void
45
-    {}
44
+protected function after(): void
45
+{}
46 46
 
47
-    /**
47
+/**
48 48
      * Set the attached DOM node content with the component HTML code.
49 49
      *
50 50
      * @return void
51 51
      */
52
-    final public function render(): void
53
-    {
54
-        $this->before();
55
-        $this->node()->html((string)$this->html());
56
-        $this->after();
57
-    }
52
+final public function render(): void
53
+{
54
+$this->before();
55
+$this->node()->html((string)$this->html());
56
+$this->after();
57
+}
58 58
 
59
-    /**
59
+/**
60 60
      * Clear the attached DOM node content.
61 61
      *
62 62
      * @return void
63 63
      */
64
-    final public function clear(): void
65
-    {
66
-        $this->node()->clear();
67
-    }
64
+final public function clear(): void
65
+{
66
+$this->node()->clear();
67
+}
68 68
 
69
-    /**
69
+/**
70 70
      * Show/hide the attached DOM node.
71 71
      *
72 72
      * @return void
73 73
      */
74
-    final public function visible(bool $bVisible): void
75
-    {
76
-        $bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide();
77
-    }
74
+final public function visible(bool $bVisible): void
75
+{
76
+$bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide();
77
+}
78 78
 }
Please login to merge, or discard this patch.