Passed
Push — main ( 7c5fe7...238af9 )
by Thierry
16:11
created
jaxon-core/src/App/Ajax/Bootstrap.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             'export' => $bExport,
92 92
             'minify' => $bMinify,
93 93
         ];
94
-        if($sUri !== '')
94
+        if ($sUri !== '')
95 95
         {
96 96
             $aJsOptions['uri'] = $sUri;
97 97
         }
98
-        if($sDir !== '')
98
+        if ($sDir !== '')
99 99
         {
100 100
             $aJsOptions['dir'] = $sDir;
101 101
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         // Popping the callbacks makes each of them to be called once.
153 153
         $aBootCallbacks = $this->xCallbackManager->popBootCallbacks();
154
-        foreach($aBootCallbacks as $aBootCallback)
154
+        foreach ($aBootCallbacks as $aBootCallback)
155 155
         {
156 156
             call_user_func($aBootCallback);
157 157
         }
Please login to merge, or discard this patch.
Switch Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@  discard block
 block discarded – undo
23 23
 
24 24
 class Bootstrap
25 25
 {
26
-    /**
26
+/**
27 27
      * The library options
28 28
      *
29 29
      * @var array
30 30
      */
31
-    private $aLibOptions = [];
31
+private $aLibOptions = [];
32 32
 
33
-    /**
33
+/**
34 34
      * The application options
35 35
      *
36 36
      * @var array
37 37
      */
38
-    private $aAppOptions = [];
38
+private $aAppOptions = [];
39 39
 
40
-    /**
40
+/**
41 41
      * The class constructor
42 42
      *
43 43
      * @param ConfigManager $xConfigManager
44 44
      * @param PackageManager $xPackageManager
45 45
      * @param CallbackManager $xCallbackManager
46 46
      */
47
-    public function __construct(private ConfigManager $xConfigManager,
48
-        private PackageManager $xPackageManager, private CallbackManager $xCallbackManager)
49
-    {}
47
+public function __construct(private ConfigManager $xConfigManager,
48
+private PackageManager $xPackageManager, private CallbackManager $xCallbackManager)
49
+{}
50 50
 
51
-    /**
51
+/**
52 52
      * Set the library options
53 53
      *
54 54
      * @param array $aLibOptions    The library options
55 55
      *
56 56
      * @return Bootstrap
57 57
      */
58
-    public function lib(array $aLibOptions): Bootstrap
59
-    {
60
-        $this->aLibOptions = $aLibOptions;
61
-        return $this;
62
-    }
58
+public function lib(array $aLibOptions): Bootstrap
59
+{
60
+$this->aLibOptions = $aLibOptions;
61
+return $this;
62
+}
63 63
 
64
-    /**
64
+/**
65 65
      * Set the applications options
66 66
      *
67 67
      * @param array $aAppOptions    The application options
68 68
      *
69 69
      * @return Bootstrap
70 70
      */
71
-    public function app(array $aAppOptions): Bootstrap
72
-    {
73
-        $this->aAppOptions = $aAppOptions;
74
-        return $this;
75
-    }
71
+public function app(array $aAppOptions): Bootstrap
72
+{
73
+$this->aAppOptions = $aAppOptions;
74
+return $this;
75
+}
76 76
 
77
-    /**
77
+/**
78 78
      * Set the javascript asset
79 79
      *
80 80
      * @param bool $bExport    Whether to export the js code in a file
@@ -84,76 +84,76 @@  discard block
 block discarded – undo
84 84
      *
85 85
      * @return Bootstrap
86 86
      */
87
-    public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): Bootstrap
88
-    {
89
-        // Jaxon library settings
90
-        $aJsOptions = [
91
-            'export' => $bExport,
92
-            'minify' => $bMinify,
93
-        ];
94
-        if($sUri !== '')
95
-        {
96
-            $aJsOptions['uri'] = $sUri;
97
-        }
98
-        if($sDir !== '')
99
-        {
100
-            $aJsOptions['dir'] = $sDir;
101
-        }
102
-        $this->xConfigManager->setOptions($aJsOptions, 'js.app');
103
-        return $this;
104
-    }
87
+public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): Bootstrap
88
+{
89
+// Jaxon library settings
90
+$aJsOptions = [
91
+'export' => $bExport,
92
+'minify' => $bMinify,
93
+];
94
+if($sUri !== '')
95
+{
96
+$aJsOptions['uri'] = $sUri;
97
+}
98
+if($sDir !== '')
99
+{
100
+$aJsOptions['dir'] = $sDir;
101
+}
102
+$this->xConfigManager->setOptions($aJsOptions, 'js.app');
103
+return $this;
104
+}
105 105
 
106
-    /**
106
+/**
107 107
      * Set the Jaxon application options.
108 108
      *
109 109
      * @return void
110 110
      * @throws SetupException
111 111
      */
112
-    private function setupApp(): void
113
-    {
114
-        // Save the app config.
115
-        $this->xConfigManager->setAppOptions($this->aAppOptions);
116
-        // Register user functions and classes
117
-        $this->xPackageManager->registerFromConfig();
118
-    }
112
+private function setupApp(): void
113
+{
114
+// Save the app config.
115
+$this->xConfigManager->setAppOptions($this->aAppOptions);
116
+// Register user functions and classes
117
+$this->xPackageManager->registerFromConfig();
118
+}
119 119
 
120
-    /**
120
+/**
121 121
      * Wraps the module/package/bundle setup method.
122 122
      *
123 123
      * @return void
124 124
      * @throws SetupException
125 125
      */
126
-    public function setup(): void
127
-    {
128
-        // Prevent the Jaxon library from sending the response or exiting
129
-        $this->xConfigManager->setOptions([
130
-            'response' => [
131
-                'send' => false,
132
-            ],
133
-            'process' => [
134
-                'exit' => false,
135
-            ],
136
-        ], 'core');
137
-        // Setup the lib config options.
138
-        $this->xConfigManager->setOptions($this->aLibOptions);
126
+public function setup(): void
127
+{
128
+// Prevent the Jaxon library from sending the response or exiting
129
+$this->xConfigManager->setOptions([
130
+'response' => [
131
+    'send' => false,
132
+],
133
+'process' => [
134
+    'exit' => false,
135
+],
136
+], 'core');
137
+// Setup the lib config options.
138
+$this->xConfigManager->setOptions($this->aLibOptions);
139 139
 
140
-        // Setup the app.
141
-        $this->setupApp();
142
-        $this->onBoot();
143
-    }
140
+// Setup the app.
141
+$this->setupApp();
142
+$this->onBoot();
143
+}
144 144
 
145
-    /**
145
+/**
146 146
      * These callbacks are called once, after the library is initialized.
147 147
      *
148 148
      * @return void
149 149
      */
150
-    public function onBoot(): void
151
-    {
152
-        // Popping the callbacks makes each of them to be called once.
153
-        $aBootCallbacks = $this->xCallbackManager->popBootCallbacks();
154
-        foreach($aBootCallbacks as $aBootCallback)
155
-        {
156
-            call_user_func($aBootCallback);
157
-        }
158
-    }
150
+public function onBoot(): void
151
+{
152
+// Popping the callbacks makes each of them to be called once.
153
+$aBootCallbacks = $this->xCallbackManager->popBootCallbacks();
154
+foreach($aBootCallbacks as $aBootCallback)
155
+{
156
+call_user_func($aBootCallback);
157
+}
158
+}
159 159
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/App.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function setup(string $sConfigFile = ''): void
31 31
     {
32
-        if(!file_exists($sConfigFile))
32
+        if (!file_exists($sConfigFile))
33 33
         {
34 34
             throw new SetupException($this->translator()
35 35
                 ->trans('errors.file.access', ['path' => $sConfigFile]));
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
         $aOptions = $this->config()->read($sConfigFile);
40 40
         $aLibOptions = $aOptions['lib'] ?? [];
41 41
         $aAppOptions = $aOptions['app'] ?? [];
42
-        if(!is_array($aLibOptions) || !is_array($aAppOptions))
42
+        if (!is_array($aLibOptions) || !is_array($aAppOptions))
43 43
         {
44 44
             throw new SetupException($sMessage = $this->translator()
45 45
                 ->trans('errors.file.content', ['path' => $sConfigFile]));
46 46
         }
47 47
 
48 48
         // The bootstrap set this to false. It needs to be changed.
49
-        if(!isset($aLibOptions['core']['response']['send']))
49
+        if (!isset($aLibOptions['core']['response']['send']))
50 50
         {
51 51
             $aLibOptions['core']['response']['send'] = true;
52 52
         }
Please login to merge, or discard this patch.
Switch Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@
 block discarded – undo
21 21
 
22 22
 class App extends AbstractApp
23 23
 {
24
-    use Traits\SendResponseTrait;
24
+use Traits\SendResponseTrait;
25 25
 
26
-    /**
26
+/**
27 27
      * @inheritDoc
28 28
      * @throws SetupException
29 29
      */
30
-    public function setup(string $sConfigFile = ''): void
31
-    {
32
-        if(!file_exists($sConfigFile))
33
-        {
34
-            throw new SetupException($this->translator()
35
-                ->trans('errors.file.access', ['path' => $sConfigFile]));
36
-        }
37
-
38
-        // Read the config options.
39
-        $aOptions = $this->config()->read($sConfigFile);
40
-        $aLibOptions = $aOptions['lib'] ?? [];
41
-        $aAppOptions = $aOptions['app'] ?? [];
42
-        if(!is_array($aLibOptions) || !is_array($aAppOptions))
43
-        {
44
-            throw new SetupException($sMessage = $this->translator()
45
-                ->trans('errors.file.content', ['path' => $sConfigFile]));
46
-        }
47
-
48
-        // The bootstrap set this to false. It needs to be changed.
49
-        if(!isset($aLibOptions['core']['response']['send']))
50
-        {
51
-            $aLibOptions['core']['response']['send'] = true;
52
-        }
53
-
54
-        $this->bootstrap()
55
-            ->lib($aLibOptions)
56
-            ->app($aAppOptions)
57
-            ->setup();
58
-    }
30
+public function setup(string $sConfigFile = ''): void
31
+{
32
+if(!file_exists($sConfigFile))
33
+{
34
+throw new SetupException($this->translator()
35
+    ->trans('errors.file.access', ['path' => $sConfigFile]));
36
+}
37
+
38
+// Read the config options.
39
+$aOptions = $this->config()->read($sConfigFile);
40
+$aLibOptions = $aOptions['lib'] ?? [];
41
+$aAppOptions = $aOptions['app'] ?? [];
42
+if(!is_array($aLibOptions) || !is_array($aAppOptions))
43
+{
44
+throw new SetupException($sMessage = $this->translator()
45
+    ->trans('errors.file.content', ['path' => $sConfigFile]));
46
+}
47
+
48
+// The bootstrap set this to false. It needs to be changed.
49
+if(!isset($aLibOptions['core']['response']['send']))
50
+{
51
+$aLibOptions['core']['response']['send'] = true;
52
+}
53
+
54
+$this->bootstrap()
55
+->lib($aLibOptions)
56
+->app($aAppOptions)
57
+->setup();
58
+}
59 59
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/Traits/SendResponseTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function httpResponse(string $sCode = '200'): mixed
61 61
     {
62
-        if(!$this->config()->getOption('core.response.send', false))
62
+        if (!$this->config()->getOption('core.response.send', false))
63 63
         {
64 64
             return null;
65 65
         }
66 66
 
67 67
         // Check to see if headers have already been sent out, in which case we can't do our job
68
-        if(headers_sent($sFilename, $nLineNumber))
68
+        if (headers_sent($sFilename, $nLineNumber))
69 69
         {
70 70
             throw new RequestException($this->translator()
71 71
                 ->trans('errors.output.already-sent', [
72 72
                     'location' => "$sFilename:$nLineNumber",
73 73
                 ]) . "\n" . $this->translator()->trans('errors.output.advice'));
74 74
         }
75
-        if(empty($sContent = $this->getResponseManager()->getOutput()))
75
+        if (empty($sContent = $this->getResponseManager()->getOutput()))
76 76
         {
77 77
             return null;
78 78
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         // Set the HTTP response code
81 81
         http_response_code(intval($sCode));
82 82
 
83
-        if($this->di()->getRequest()->getMethod() === 'GET')
83
+        if ($this->di()->getRequest()->getMethod() === 'GET')
84 84
         {
85 85
             header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86 86
             header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         header('Content-Type: ' . $this->getResponseManager()->getContentType());
91 91
 
92 92
         print $sContent;
93
-        if($this->config()->getOption('core.process.exit', false))
93
+        if ($this->config()->getOption('core.process.exit', false))
94 94
         {
95 95
             exit();
96 96
         }
Please login to merge, or discard this patch.
Switch Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -31,69 +31,69 @@
 block discarded – undo
31 31
 
32 32
 trait SendResponseTrait
33 33
 {
34
-    /**
34
+/**
35 35
      * @return Container
36 36
      */
37
-    abstract public function di(): Container;
37
+abstract public function di(): Container;
38 38
 
39
-    /**
39
+/**
40 40
      * @return ConfigManager
41 41
      */
42
-    abstract public function config(): ConfigManager;
42
+abstract public function config(): ConfigManager;
43 43
 
44
-    /**
44
+/**
45 45
      * @return Translator
46 46
      */
47
-    abstract public function translator(): Translator;
47
+abstract public function translator(): Translator;
48 48
 
49
-    /**
49
+/**
50 50
      * @return ResponseManager
51 51
      */
52
-    abstract public function getResponseManager(): ResponseManager;
52
+abstract public function getResponseManager(): ResponseManager;
53 53
 
54
-    /**
54
+/**
55 55
      * Prints the response to the output stream, thus sending the response to the browser
56 56
      *
57 57
      * @return mixed
58 58
      * @throws RequestException
59 59
      */
60
-    public function httpResponse(string $sCode = '200'): mixed
61
-    {
62
-        if(!$this->config()->getOption('core.response.send', false))
63
-        {
64
-            return null;
65
-        }
60
+public function httpResponse(string $sCode = '200'): mixed
61
+{
62
+if(!$this->config()->getOption('core.response.send', false))
63
+{
64
+return null;
65
+}
66 66
 
67
-        // Check to see if headers have already been sent out, in which case we can't do our job
68
-        if(headers_sent($sFilename, $nLineNumber))
69
-        {
70
-            throw new RequestException($this->translator()
71
-                ->trans('errors.output.already-sent', [
72
-                    'location' => "$sFilename:$nLineNumber",
73
-                ]) . "\n" . $this->translator()->trans('errors.output.advice'));
74
-        }
75
-        if(empty($sContent = $this->getResponseManager()->getOutput()))
76
-        {
77
-            return null;
78
-        }
67
+// Check to see if headers have already been sent out, in which case we can't do our job
68
+if(headers_sent($sFilename, $nLineNumber))
69
+{
70
+throw new RequestException($this->translator()
71
+    ->trans('errors.output.already-sent', [
72
+        'location' => "$sFilename:$nLineNumber",
73
+    ]) . "\n" . $this->translator()->trans('errors.output.advice'));
74
+}
75
+if(empty($sContent = $this->getResponseManager()->getOutput()))
76
+{
77
+return null;
78
+}
79 79
 
80
-        // Set the HTTP response code
81
-        http_response_code(intval($sCode));
80
+// Set the HTTP response code
81
+http_response_code(intval($sCode));
82 82
 
83
-        if($this->di()->getRequest()->getMethod() === 'GET')
84
-        {
85
-            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86
-            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
87
-            header("Cache-Control: no-cache, must-revalidate");
88
-            header("Pragma: no-cache");
89
-        }
90
-        header('Content-Type: ' . $this->getResponseManager()->getContentType());
83
+if($this->di()->getRequest()->getMethod() === 'GET')
84
+{
85
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
87
+header("Cache-Control: no-cache, must-revalidate");
88
+header("Pragma: no-cache");
89
+}
90
+header('Content-Type: ' . $this->getResponseManager()->getContentType());
91 91
 
92
-        print $sContent;
93
-        if($this->config()->getOption('core.process.exit', false))
94
-        {
95
-            exit();
96
-        }
97
-        return null;
98
-    }
92
+print $sContent;
93
+if($this->config()->getOption('core.process.exit', false))
94
+{
95
+exit();
96
+}
97
+return null;
98
+}
99 99
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Config/ConfigManager.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
         {
71 71
             return $this->xConfigReader->read($sConfigFile);
72 72
         }
73
-        catch(YamlExtension $e)
73
+        catch (YamlExtension $e)
74 74
         {
75 75
             $sMessage = $this->xTranslator->trans('errors.yaml.install');
76 76
             throw new SetupException($sMessage);
77 77
         }
78
-        catch(FileExtension $e)
78
+        catch (FileExtension $e)
79 79
         {
80 80
             $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]);
81 81
             throw new SetupException($sMessage);
82 82
         }
83
-        catch(FileAccess $e)
83
+        catch (FileAccess $e)
84 84
         {
85 85
             $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]);
86 86
             throw new SetupException($sMessage);
87 87
         }
88
-        catch(FileContent $e)
88
+        catch (FileContent $e)
89 89
         {
90 90
             $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]);
91 91
             throw new SetupException($sMessage);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             // Call the config change listeners.
112 112
             $this->xEventManager->libConfigChanged($this->xLibConfig, '');
113 113
         }
114
-        catch(DataDepth $e)
114
+        catch (DataDepth $e)
115 115
         {
116 116
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
117 117
                 'key' => $e->sPrefix,
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $this->xEventManager->libConfigChanged($this->xLibConfig, '');
141 141
             return $this->xLibConfig->changed();
142 142
         }
143
-        catch(DataDepth $e)
143
+        catch (DataDepth $e)
144 144
         {
145 145
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
146 146
                 'key' => $e->sPrefix,
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $this->xEventManager->appConfigChanged($this->xAppConfig, '');
248 248
             return $this->xAppConfig->changed();
249 249
         }
250
-        catch(DataDepth $e)
250
+        catch (DataDepth $e)
251 251
         {
252 252
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
253 253
                 'key' => $e->sPrefix,
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         {
298 298
             return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix);
299 299
         }
300
-        catch(DataDepth $e)
300
+        catch (DataDepth $e)
301 301
         {
302 302
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
303 303
                 'key' => $e->sPrefix,
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function globals(bool $bForce = false): void
338 338
     {
339
-        if($bForce || $this->getAppOption('helpers.global', true))
339
+        if ($bForce || $this->getAppOption('helpers.global', true))
340 340
         {
341 341
             require_once dirname(__DIR__, 2) . '/globals.php';
342 342
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -69,23 +69,19 @@  discard block
 block discarded – undo
69 69
         try
70 70
         {
71 71
             return $this->xConfigReader->read($sConfigFile);
72
-        }
73
-        catch(YamlExtension $e)
72
+        } catch(YamlExtension $e)
74 73
         {
75 74
             $sMessage = $this->xTranslator->trans('errors.yaml.install');
76 75
             throw new SetupException($sMessage);
77
-        }
78
-        catch(FileExtension $e)
76
+        } catch(FileExtension $e)
79 77
         {
80 78
             $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]);
81 79
             throw new SetupException($sMessage);
82
-        }
83
-        catch(FileAccess $e)
80
+        } catch(FileAccess $e)
84 81
         {
85 82
             $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]);
86 83
             throw new SetupException($sMessage);
87
-        }
88
-        catch(FileContent $e)
84
+        } catch(FileContent $e)
89 85
         {
90 86
             $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]);
91 87
             throw new SetupException($sMessage);
@@ -110,8 +106,7 @@  discard block
 block discarded – undo
110 106
                 ->setOptions($this->xLibConfig, $this->read($sConfigFile), $sConfigSection);
111 107
             // Call the config change listeners.
112 108
             $this->xEventManager->libConfigChanged($this->xLibConfig, '');
113
-        }
114
-        catch(DataDepth $e)
109
+        } catch(DataDepth $e)
115 110
         {
116 111
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
117 112
                 'key' => $e->sPrefix,
@@ -139,8 +134,7 @@  discard block
 block discarded – undo
139 134
             // Call the config change listeners.
140 135
             $this->xEventManager->libConfigChanged($this->xLibConfig, '');
141 136
             return $this->xLibConfig->changed();
142
-        }
143
-        catch(DataDepth $e)
137
+        } catch(DataDepth $e)
144 138
         {
145 139
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
146 140
                 'key' => $e->sPrefix,
@@ -246,8 +240,7 @@  discard block
 block discarded – undo
246 240
             // Call the config change listeners.
247 241
             $this->xEventManager->appConfigChanged($this->xAppConfig, '');
248 242
             return $this->xAppConfig->changed();
249
-        }
250
-        catch(DataDepth $e)
243
+        } catch(DataDepth $e)
251 244
         {
252 245
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
253 246
                 'key' => $e->sPrefix,
@@ -296,8 +289,7 @@  discard block
 block discarded – undo
296 289
         try
297 290
         {
298 291
             return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix);
299
-        }
300
-        catch(DataDepth $e)
292
+        } catch(DataDepth $e)
301 293
         {
302 294
             $sMessage = $this->xTranslator->trans('errors.data.depth', [
303 295
                 'key' => $e->sPrefix,
Please login to merge, or discard this patch.
Switch Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 
30 30
 class ConfigManager
31 31
 {
32
-    /**
32
+/**
33 33
      * @var Config
34 34
      */
35
-    protected $xLibConfig;
35
+protected $xLibConfig;
36 36
 
37
-    /**
37
+/**
38 38
      * @var Config
39 39
      */
40
-    protected $xAppConfig;
40
+protected $xAppConfig;
41 41
 
42
-    /**
42
+/**
43 43
      * The constructor
44 44
      *
45 45
      * @param array $aDefaultOptions
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
      * @param ConfigSetter $xConfigSetter
49 49
      * @param ConfigEventManager $xEventManager
50 50
      */
51
-    public function __construct(array $aDefaultOptions, private Translator $xTranslator,
52
-        private ConfigReader $xConfigReader, private ConfigSetter $xConfigSetter,
53
-        private ConfigEventManager $xEventManager)
54
-    {
55
-        $this->xLibConfig = $xConfigSetter->newConfig($aDefaultOptions);
56
-        $this->xAppConfig = $xConfigSetter->newConfig();
57
-    }
51
+public function __construct(array $aDefaultOptions, private Translator $xTranslator,
52
+private ConfigReader $xConfigReader, private ConfigSetter $xConfigSetter,
53
+private ConfigEventManager $xEventManager)
54
+{
55
+$this->xLibConfig = $xConfigSetter->newConfig($aDefaultOptions);
56
+$this->xAppConfig = $xConfigSetter->newConfig();
57
+}
58 58
 
59
-    /**
59
+/**
60 60
      * Read a config file
61 61
      *
62 62
      * @param string $sConfigFile
@@ -64,35 +64,35 @@  discard block
 block discarded – undo
64 64
      * @return array
65 65
      * @throws SetupException
66 66
      */
67
-    public function read(string $sConfigFile): array
68
-    {
69
-        try
70
-        {
71
-            return $this->xConfigReader->read($sConfigFile);
72
-        }
73
-        catch(YamlExtension $e)
74
-        {
75
-            $sMessage = $this->xTranslator->trans('errors.yaml.install');
76
-            throw new SetupException($sMessage);
77
-        }
78
-        catch(FileExtension $e)
79
-        {
80
-            $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]);
81
-            throw new SetupException($sMessage);
82
-        }
83
-        catch(FileAccess $e)
84
-        {
85
-            $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]);
86
-            throw new SetupException($sMessage);
87
-        }
88
-        catch(FileContent $e)
89
-        {
90
-            $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]);
91
-            throw new SetupException($sMessage);
92
-        }
93
-    }
67
+public function read(string $sConfigFile): array
68
+{
69
+try
70
+{
71
+return $this->xConfigReader->read($sConfigFile);
72
+}
73
+catch(YamlExtension $e)
74
+{
75
+$sMessage = $this->xTranslator->trans('errors.yaml.install');
76
+throw new SetupException($sMessage);
77
+}
78
+catch(FileExtension $e)
79
+{
80
+$sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]);
81
+throw new SetupException($sMessage);
82
+}
83
+catch(FileAccess $e)
84
+{
85
+$sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]);
86
+throw new SetupException($sMessage);
87
+}
88
+catch(FileContent $e)
89
+{
90
+$sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]);
91
+throw new SetupException($sMessage);
92
+}
93
+}
94 94
 
95
-    /**
95
+/**
96 96
      * Read options from a config file and set the library config
97 97
      *
98 98
      * @param string $sConfigFile The full path to the config file
@@ -101,27 +101,27 @@  discard block
 block discarded – undo
101 101
      * @return void
102 102
      * @throws SetupException
103 103
      */
104
-    public function load(string $sConfigFile, string $sConfigSection = ''): void
105
-    {
106
-        try
107
-        {
108
-            // Read the options and save in the config.
109
-            $this->xLibConfig = $this->xConfigSetter
110
-                ->setOptions($this->xLibConfig, $this->read($sConfigFile), $sConfigSection);
111
-            // Call the config change listeners.
112
-            $this->xEventManager->libConfigChanged($this->xLibConfig, '');
113
-        }
114
-        catch(DataDepth $e)
115
-        {
116
-            $sMessage = $this->xTranslator->trans('errors.data.depth', [
117
-                'key' => $e->sPrefix,
118
-                'depth' => $e->nDepth,
119
-            ]);
120
-            throw new SetupException($sMessage);
121
-        }
122
-    }
104
+public function load(string $sConfigFile, string $sConfigSection = ''): void
105
+{
106
+try
107
+{
108
+// Read the options and save in the config.
109
+$this->xLibConfig = $this->xConfigSetter
110
+    ->setOptions($this->xLibConfig, $this->read($sConfigFile), $sConfigSection);
111
+// Call the config change listeners.
112
+$this->xEventManager->libConfigChanged($this->xLibConfig, '');
113
+}
114
+catch(DataDepth $e)
115
+{
116
+$sMessage = $this->xTranslator->trans('errors.data.depth', [
117
+    'key' => $e->sPrefix,
118
+    'depth' => $e->nDepth,
119
+]);
120
+throw new SetupException($sMessage);
121
+}
122
+}
123 123
 
124
-    /**
124
+/**
125 125
      * Set the config options of the library
126 126
      *
127 127
      * @param array $aOptions
@@ -130,27 +130,27 @@  discard block
 block discarded – undo
130 130
      * @return bool
131 131
      * @throws SetupException
132 132
      */
133
-    public function setOptions(array $aOptions, string $sNamePrefix = ''): bool
134
-    {
135
-        try
136
-        {
137
-            $this->xLibConfig = $this->xConfigSetter
138
-                ->setOptions($this->xLibConfig, $aOptions, $sNamePrefix);
139
-            // Call the config change listeners.
140
-            $this->xEventManager->libConfigChanged($this->xLibConfig, '');
141
-            return $this->xLibConfig->changed();
142
-        }
143
-        catch(DataDepth $e)
144
-        {
145
-            $sMessage = $this->xTranslator->trans('errors.data.depth', [
146
-                'key' => $e->sPrefix,
147
-                'depth' => $e->nDepth,
148
-            ]);
149
-            throw new SetupException($sMessage);
150
-        }
151
-    }
133
+public function setOptions(array $aOptions, string $sNamePrefix = ''): bool
134
+{
135
+try
136
+{
137
+$this->xLibConfig = $this->xConfigSetter
138
+    ->setOptions($this->xLibConfig, $aOptions, $sNamePrefix);
139
+// Call the config change listeners.
140
+$this->xEventManager->libConfigChanged($this->xLibConfig, '');
141
+return $this->xLibConfig->changed();
142
+}
143
+catch(DataDepth $e)
144
+{
145
+$sMessage = $this->xTranslator->trans('errors.data.depth', [
146
+    'key' => $e->sPrefix,
147
+    'depth' => $e->nDepth,
148
+]);
149
+throw new SetupException($sMessage);
150
+}
151
+}
152 152
 
153
-    /**
153
+/**
154 154
      * Set the value of a config option
155 155
      *
156 156
      * @param string $sName The option name
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
      *
159 159
      * @return void
160 160
      */
161
-    public function setOption(string $sName, $xValue): void
162
-    {
163
-        $this->xLibConfig = $this->xConfigSetter
164
-            ->setOption($this->xLibConfig, $sName, $xValue);
165
-        // Call the config change listeners.
166
-        $this->xEventManager->libConfigChanged($this->xLibConfig, $sName);
167
-    }
161
+public function setOption(string $sName, $xValue): void
162
+{
163
+$this->xLibConfig = $this->xConfigSetter
164
+->setOption($this->xLibConfig, $sName, $xValue);
165
+// Call the config change listeners.
166
+$this->xEventManager->libConfigChanged($this->xLibConfig, $sName);
167
+}
168 168
 
169
-    /**
169
+/**
170 170
      * Get the value of a config option
171 171
      *
172 172
      * @param string $sName The option name
@@ -174,36 +174,36 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @return mixed
176 176
      */
177
-    public function getOption(string $sName, $xDefault = null): mixed
178
-    {
179
-        return $this->xLibConfig->getOption($sName, $xDefault);
180
-    }
177
+public function getOption(string $sName, $xDefault = null): mixed
178
+{
179
+return $this->xLibConfig->getOption($sName, $xDefault);
180
+}
181 181
 
182
-    /**
182
+/**
183 183
      * Check the presence of a config option
184 184
      *
185 185
      * @param string $sName The option name
186 186
      *
187 187
      * @return bool
188 188
      */
189
-    public function hasOption(string $sName): bool
190
-    {
191
-        return $this->xLibConfig->hasOption($sName);
192
-    }
189
+public function hasOption(string $sName): bool
190
+{
191
+return $this->xLibConfig->hasOption($sName);
192
+}
193 193
 
194
-    /**
194
+/**
195 195
      * Get the names of the options matching a given prefix
196 196
      *
197 197
      * @param string $sPrefix The prefix to match
198 198
      *
199 199
      * @return array
200 200
      */
201
-    public function getOptionNames(string $sPrefix): array
202
-    {
203
-        return $this->xLibConfig->getOptionNames($sPrefix);
204
-    }
201
+public function getOptionNames(string $sPrefix): array
202
+{
203
+return $this->xLibConfig->getOptionNames($sPrefix);
204
+}
205 205
 
206
-    /**
206
+/**
207 207
      * Set the value of a config option
208 208
      *
209 209
      * @param string $sName The option name
@@ -211,25 +211,25 @@  discard block
 block discarded – undo
211 211
      *
212 212
      * @return void
213 213
      */
214
-    public function setAppOption(string $sName, $xValue): void
215
-    {
216
-        $this->xAppConfig = $this->xConfigSetter
217
-            ->setOption($this->xAppConfig, $sName, $xValue);
218
-        // Call the config change listeners.
219
-        $this->xEventManager->appConfigChanged($this->xAppConfig, $sName);
220
-    }
214
+public function setAppOption(string $sName, $xValue): void
215
+{
216
+$this->xAppConfig = $this->xConfigSetter
217
+->setOption($this->xAppConfig, $sName, $xValue);
218
+// Call the config change listeners.
219
+$this->xEventManager->appConfigChanged($this->xAppConfig, $sName);
220
+}
221 221
 
222
-    /**
222
+/**
223 223
      * Get the application config
224 224
      *
225 225
      * @return Config
226 226
      */
227
-    public function getAppConfig(): Config
228
-    {
229
-        return $this->xAppConfig;
230
-    }
227
+public function getAppConfig(): Config
228
+{
229
+return $this->xAppConfig;
230
+}
231 231
 
232
-    /**
232
+/**
233 233
      * Set the application config options
234 234
      *
235 235
      * @param array $aAppOptions
@@ -237,27 +237,27 @@  discard block
 block discarded – undo
237 237
      *
238 238
      * @return bool
239 239
      */
240
-    public function setAppOptions(array $aAppOptions, string $sNamePrefix = ''): bool
241
-    {
242
-        try
243
-        {
244
-            $this->xAppConfig = $this->xConfigSetter
245
-                ->setOptions($this->xAppConfig, $aAppOptions, $sNamePrefix);
246
-            // Call the config change listeners.
247
-            $this->xEventManager->appConfigChanged($this->xAppConfig, '');
248
-            return $this->xAppConfig->changed();
249
-        }
250
-        catch(DataDepth $e)
251
-        {
252
-            $sMessage = $this->xTranslator->trans('errors.data.depth', [
253
-                'key' => $e->sPrefix,
254
-                'depth' => $e->nDepth,
255
-            ]);
256
-            throw new SetupException($sMessage);
257
-        }
258
-    }
240
+public function setAppOptions(array $aAppOptions, string $sNamePrefix = ''): bool
241
+{
242
+try
243
+{
244
+$this->xAppConfig = $this->xConfigSetter
245
+    ->setOptions($this->xAppConfig, $aAppOptions, $sNamePrefix);
246
+// Call the config change listeners.
247
+$this->xEventManager->appConfigChanged($this->xAppConfig, '');
248
+return $this->xAppConfig->changed();
249
+}
250
+catch(DataDepth $e)
251
+{
252
+$sMessage = $this->xTranslator->trans('errors.data.depth', [
253
+    'key' => $e->sPrefix,
254
+    'depth' => $e->nDepth,
255
+]);
256
+throw new SetupException($sMessage);
257
+}
258
+}
259 259
 
260
-    /**
260
+/**
261 261
      * Get the value of an application config option
262 262
      *
263 263
      * @param string $sName The option name
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
      *
266 266
      * @return mixed
267 267
      */
268
-    public function getAppOption(string $sName, $xDefault = null): mixed
269
-    {
270
-        return $this->xAppConfig->getOption($sName, $xDefault);
271
-    }
268
+public function getAppOption(string $sName, $xDefault = null): mixed
269
+{
270
+return $this->xAppConfig->getOption($sName, $xDefault);
271
+}
272 272
 
273
-    /**
273
+/**
274 274
      * Check the presence of an application config option
275 275
      *
276 276
      * @param string $sName The option name
277 277
      *
278 278
      * @return bool
279 279
      */
280
-    public function hasAppOption(string $sName): bool
281
-    {
282
-        return $this->xAppConfig->hasOption($sName);
283
-    }
280
+public function hasAppOption(string $sName): bool
281
+{
282
+return $this->xAppConfig->hasOption($sName);
283
+}
284 284
 
285
-    /**
285
+/**
286 286
      * Create a new the config object
287 287
      *
288 288
      * @param array $aOptions     The options array
@@ -291,54 +291,54 @@  discard block
 block discarded – undo
291 291
      * @return Config
292 292
      * @throws SetupException
293 293
      */
294
-    public function newConfig(array $aOptions = [], string $sNamePrefix = ''): Config
295
-    {
296
-        try
297
-        {
298
-            return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix);
299
-        }
300
-        catch(DataDepth $e)
301
-        {
302
-            $sMessage = $this->xTranslator->trans('errors.data.depth', [
303
-                'key' => $e->sPrefix,
304
-                'depth' => $e->nDepth,
305
-            ]);
306
-            throw new SetupException($sMessage);
307
-        }
308
-    }
294
+public function newConfig(array $aOptions = [], string $sNamePrefix = ''): Config
295
+{
296
+try
297
+{
298
+return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix);
299
+}
300
+catch(DataDepth $e)
301
+{
302
+$sMessage = $this->xTranslator->trans('errors.data.depth', [
303
+    'key' => $e->sPrefix,
304
+    'depth' => $e->nDepth,
305
+]);
306
+throw new SetupException($sMessage);
307
+}
308
+}
309 309
 
310
-    /**
310
+/**
311 311
      * @param string $sClassName
312 312
      *
313 313
      * @return void
314 314
      */
315
-    public function addLibEventListener(string $sClassName): void
316
-    {
317
-        $this->xEventManager->addLibConfigListener($sClassName);
318
-    }
315
+public function addLibEventListener(string $sClassName): void
316
+{
317
+$this->xEventManager->addLibConfigListener($sClassName);
318
+}
319 319
 
320
-    /**
320
+/**
321 321
      * @param string $sClassName
322 322
      *
323 323
      * @return void
324 324
      */
325
-    public function addAppEventListener(string $sClassName): void
326
-    {
327
-        $this->xEventManager->addAppConfigListener($sClassName);
328
-    }
325
+public function addAppEventListener(string $sClassName): void
326
+{
327
+$this->xEventManager->addAppConfigListener($sClassName);
328
+}
329 329
 
330
-    /**
330
+/**
331 331
      * Make the helpers functions available in the global namespace.
332 332
      *
333 333
      * @param bool $bForce
334 334
      *
335 335
      * @return void
336 336
      */
337
-    public function globals(bool $bForce = false): void
338
-    {
339
-        if($bForce || $this->getAppOption('helpers.global', true))
340
-        {
341
-            require_once dirname(__DIR__, 2) . '/globals.php';
342
-        }
343
-    }
337
+public function globals(bool $bForce = false): void
338
+{
339
+if($bForce || $this->getAppOption('helpers.global', true))
340
+{
341
+require_once dirname(__DIR__, 2) . '/globals.php';
342
+}
343
+}
344 344
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Config/ConfigEventManager.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function libConfigChanged(Config $xConfig, string $sName): void
62 62
     {
63
-        foreach($this->aLibConfigListeners as $sListener)
63
+        foreach ($this->aLibConfigListeners as $sListener)
64 64
         {
65 65
             $this->di->g($sListener)->onChange($xConfig, $sName);
66 66
         }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function appConfigChanged(Config $xConfig, string $sName): void
73 73
     {
74
-        foreach($this->aAppConfigListeners as $sListener)
74
+        foreach ($this->aAppConfigListeners as $sListener)
75 75
         {
76 76
             $this->di->g($sListener)->onChange($xConfig, $sName);
77 77
         }
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,61 +19,61 @@
 block discarded – undo
19 19
 
20 20
 class ConfigEventManager
21 21
 {
22
-    /**
22
+/**
23 23
      * @var string[]
24 24
      */
25
-    protected $aLibConfigListeners = [];
25
+protected $aLibConfigListeners = [];
26 26
 
27
-    /**
27
+/**
28 28
      * @var string[]
29 29
      */
30
-    protected $aAppConfigListeners = [];
30
+protected $aAppConfigListeners = [];
31 31
 
32
-    /**
32
+/**
33 33
      * @param Container $di
34 34
      */
35
-    public function __construct(private Container $di)
36
-    {}
35
+public function __construct(private Container $di)
36
+{}
37 37
 
38
-    /**
38
+/**
39 39
      * @param string $sClassName
40 40
      *
41 41
      * @return void
42 42
      */
43
-    public function addLibConfigListener(string $sClassName): void
44
-    {
45
-        $this->aLibConfigListeners[] = $sClassName;
46
-    }
43
+public function addLibConfigListener(string $sClassName): void
44
+{
45
+$this->aLibConfigListeners[] = $sClassName;
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * @param string $sClassName
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function addAppConfigListener(string $sClassName): void
54
-    {
55
-        $this->aAppConfigListeners[] = $sClassName;
56
-    }
53
+public function addAppConfigListener(string $sClassName): void
54
+{
55
+$this->aAppConfigListeners[] = $sClassName;
56
+}
57 57
 
58
-    /**
58
+/**
59 59
      * @inheritDoc
60 60
      */
61
-    public function libConfigChanged(Config $xConfig, string $sName): void
62
-    {
63
-        foreach($this->aLibConfigListeners as $sListener)
64
-        {
65
-            $this->di->g($sListener)->onChange($xConfig, $sName);
66
-        }
67
-    }
61
+public function libConfigChanged(Config $xConfig, string $sName): void
62
+{
63
+foreach($this->aLibConfigListeners as $sListener)
64
+{
65
+$this->di->g($sListener)->onChange($xConfig, $sName);
66
+}
67
+}
68 68
 
69
-    /**
69
+/**
70 70
      * @inheritDoc
71 71
      */
72
-    public function appConfigChanged(Config $xConfig, string $sName): void
73
-    {
74
-        foreach($this->aAppConfigListeners as $sListener)
75
-        {
76
-            $this->di->g($sListener)->onChange($xConfig, $sName);
77
-        }
78
-    }
72
+public function appConfigChanged(Config $xConfig, string $sName): void
73
+{
74
+foreach($this->aAppConfigListeners as $sListener)
75
+{
76
+$this->di->g($sListener)->onChange($xConfig, $sName);
77
+}
78
+}
79 79
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/UploadData.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
      */
52 52
     protected function validateField(string $sField): void
53 53
     {
54
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0)
54
+        if (preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0)
55 55
         {
56 56
             return;
57 57
         }
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -20,61 +20,61 @@
 block discarded – undo
20 20
 
21 21
 class UploadData extends AbstractData
22 22
 {
23
-    /**
23
+/**
24 24
      * The id of the upload field
25 25
      *
26 26
      * @var string
27 27
      */
28
-    protected $sField = '';
28
+protected $sField = '';
29 29
 
30
-    /**
30
+/**
31 31
      * @return string
32 32
      */
33
-    public function getName(): string
34
-    {
35
-        return 'upload';
36
-    }
33
+public function getName(): string
34
+{
35
+return 'upload';
36
+}
37 37
 
38
-    /**
38
+/**
39 39
      * @return mixed
40 40
      */
41
-    public function getValue(): mixed
42
-    {
43
-        // The field id is surrounded with simple quotes.
44
-        return "'{$this->sField}'";
45
-    }
41
+public function getValue(): mixed
42
+{
43
+// The field id is surrounded with simple quotes.
44
+return "'{$this->sField}'";
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @param string $sField
49 49
      *
50 50
      * @return void
51 51
      */
52
-    protected function validateField(string $sField): void
53
-    {
54
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0)
55
-        {
56
-            return;
57
-        }
58
-        throw new SetupException("$sField is not a valid \"field\" value for upload");
59
-    }
52
+protected function validateField(string $sField): void
53
+{
54
+if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0)
55
+{
56
+return;
57
+}
58
+throw new SetupException("$sField is not a valid \"field\" value for upload");
59
+}
60 60
 
61
-    /**
61
+/**
62 62
      * @param string $sField
63 63
      *
64 64
      * @return void
65 65
      */
66
-    public function setValue(string $sField): void
67
-    {
68
-        $this->validateField($sField);
66
+public function setValue(string $sField): void
67
+{
68
+$this->validateField($sField);
69 69
 
70
-        $this->sField = $sField;
71
-    }
70
+$this->sField = $sField;
71
+}
72 72
 
73
-    /**
73
+/**
74 74
      * @inheritDoc
75 75
      */
76
-    public function encode(string $sVarName): array
77
-    {
78
-        return ["{$sVarName}->setValue('{$this->sField}');"];
79
-    }
76
+public function encode(string $sVarName): array
77
+{
78
+return ["{$sVarName}->setValue('{$this->sField}');"];
79
+}
80 80
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/CallbackData.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
      */
51 51
     protected function validateObjectName(string $sName): void
52 52
     {
53
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
53
+        if (preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
54 54
         {
55 55
             return;
56 56
         }
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -22,61 +22,61 @@
 block discarded – undo
22 22
 
23 23
 class CallbackData extends AbstractData
24 24
 {
25
-    /**
25
+/**
26 26
      * The callback js objects
27 27
      *
28 28
      * @var array
29 29
      */
30
-    protected $aNames = [];
30
+protected $aNames = [];
31 31
 
32
-    /**
32
+/**
33 33
      * @return string
34 34
      */
35
-    public function getName(): string
36
-    {
37
-        return 'callback';
38
-    }
35
+public function getName(): string
36
+{
37
+return 'callback';
38
+}
39 39
 
40
-    /**
40
+/**
41 41
      * @return mixed
42 42
      */
43
-    public function getValue(): mixed
44
-    {
45
-        return array_values($this->aNames);
46
-    }
43
+public function getValue(): mixed
44
+{
45
+return array_values($this->aNames);
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * @param string $sName
50 50
      *
51 51
      * @return void
52 52
      */
53
-    protected function validateObjectName(string $sName): void
54
-    {
55
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
56
-        {
57
-            return;
58
-        }
59
-        throw new SetupException("$sName is not a valid \"name\" value for callback");
60
-    }
53
+protected function validateObjectName(string $sName): void
54
+{
55
+if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
56
+{
57
+return;
58
+}
59
+throw new SetupException("$sName is not a valid \"name\" value for callback");
60
+}
61 61
 
62
-    /**
62
+/**
63 63
      * @param string $sName
64 64
      *
65 65
      * @return void
66 66
      */
67
-    public function addValue(string $sName): void
68
-    {
69
-        $this->validateObjectName($sName);
67
+public function addValue(string $sName): void
68
+{
69
+$this->validateObjectName($sName);
70 70
 
71
-        $this->aNames[$sName] = $sName;
72
-    }
71
+$this->aNames[$sName] = $sName;
72
+}
73 73
 
74
-    /**
74
+/**
75 75
      * @inheritDoc
76 76
      */
77
-    public function encode(string $sVarName): array
78
-    {
79
-        return array_map(fn($sName) =>
80
-            "{$sVarName}->addValue('$sName');", $this->aNames);
81
-    }
77
+public function encode(string $sVarName): array
78
+{
79
+return array_map(fn($sName) =>
80
+"{$sVarName}->addValue('$sName');", $this->aNames);
81
+}
82 82
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Dialog/Manager/DialogCommand.php 2 patches
Spacing   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -113,8 +113,7 @@  discard block
 block discarded – undo
113 113
     private function alert(string $sType, string $sMessage, array $aArgs): array
114 114
     {
115 115
         return [
116
-            'lib' => $this->getLibrary() ?:
117
-                ($this->xRegistry?->getAlertLibrary()->getName() ?? ''),
116
+            'lib' => $this->getLibrary() ?: ($this->xRegistry?->getAlertLibrary()->getName() ?? ''),
118 117
             'message' => [
119 118
                 'type' => $sType,
120 119
                 'title' => $this->getTitle(),
@@ -197,8 +196,7 @@  discard block
 block discarded – undo
197 196
     public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []): array
198 197
     {
199 198
         return [
200
-            'lib' => $this->getLibrary() ?:
201
-                ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
199
+            'lib' => $this->getLibrary() ?: ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
202 200
             'dialog' => [
203 201
                 'title' => $sTitle,
204 202
                 'content' => $sContent,
@@ -216,8 +214,7 @@  discard block
 block discarded – undo
216 214
     public function hide(): array
217 215
     {
218 216
         return [
219
-            'lib' => $this->getLibrary() ?:
220
-                ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
217
+            'lib' => $this->getLibrary() ?: ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
221 218
         ];
222 219
     }
223 220
 
@@ -232,8 +229,7 @@  discard block
 block discarded – undo
232 229
     public function confirm(string $sQuestion, array $aArgs = []): array
233 230
     {
234 231
         return [
235
-            'lib' => $this->getLibrary() ?:
236
-                ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''),
232
+            'lib' => $this->getLibrary() ?: ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''),
237 233
             'question' => [
238 234
                 'title' => $this->getTitle(),
239 235
                 'phrase' => $this->phrase($sQuestion, $aArgs),
Please login to merge, or discard this patch.
Switch Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -19,89 +19,89 @@  discard block
 block discarded – undo
19 19
 
20 20
 class DialogCommand
21 21
 {
22
-    /**
22
+/**
23 23
      * The next alert library
24 24
      *
25 25
      * @var string
26 26
      */
27
-    private $sLibrary = '';
27
+private $sLibrary = '';
28 28
 
29
-    /**
29
+/**
30 30
      * The next alert title
31 31
      *
32 32
      * @var string
33 33
      */
34
-    private $sTitle = '';
34
+private $sTitle = '';
35 35
 
36
-    /**
36
+/**
37 37
      * The constructor
38 38
      *
39 39
      * @param LibraryRegistryInterface|null $xRegistry
40 40
      */
41
-    public function __construct(private ?LibraryRegistryInterface $xRegistry)
42
-    {}
41
+public function __construct(private ?LibraryRegistryInterface $xRegistry)
42
+{}
43 43
 
44
-    /**
44
+/**
45 45
      * Set the library for the next alert.
46 46
      *
47 47
      * @param string $sLibrary     The name of the library
48 48
      *
49 49
      * @return void
50 50
      */
51
-    public function library(string $sLibrary): void
52
-    {
53
-        $this->sLibrary = $sLibrary;
54
-    }
51
+public function library(string $sLibrary): void
52
+{
53
+$this->sLibrary = $sLibrary;
54
+}
55 55
 
56
-    /**
56
+/**
57 57
      * Set the title of the next alert.
58 58
      *
59 59
      * @param string $sTitle     The title of the alert
60 60
      *
61 61
      * @return void
62 62
      */
63
-    public function title(string $sTitle): void
64
-    {
65
-        $this->sTitle = $sTitle;
66
-    }
63
+public function title(string $sTitle): void
64
+{
65
+$this->sTitle = $sTitle;
66
+}
67 67
 
68
-    /**
68
+/**
69 69
      * @param string $sStr
70 70
      * @param array $aArgs
71 71
      *
72 72
      * @return array
73 73
      */
74
-    private function phrase(string $sStr, array $aArgs = []): array
75
-    {
76
-        return [
77
-            'str' => $sStr,
78
-            'args' => array_map(function($xArg) {
79
-                return TypedValue::make($xArg);
80
-            }, $aArgs),
81
-        ];
82
-    }
83
-
84
-    /**
74
+private function phrase(string $sStr, array $aArgs = []): array
75
+{
76
+return [
77
+'str' => $sStr,
78
+'args' => array_map(function($xArg) {
79
+    return TypedValue::make($xArg);
80
+}, $aArgs),
81
+];
82
+}
83
+
84
+/**
85 85
      * @return string
86 86
      */
87
-    private function getLibrary(): string
88
-    {
89
-        $sLibrary = $this->sLibrary;
90
-        $this->sLibrary = '';
91
-        return $sLibrary;
92
-    }
87
+private function getLibrary(): string
88
+{
89
+$sLibrary = $this->sLibrary;
90
+$this->sLibrary = '';
91
+return $sLibrary;
92
+}
93 93
 
94
-    /**
94
+/**
95 95
      * @return string
96 96
      */
97
-    private function getTitle(): string
98
-    {
99
-        $sTitle = $this->sTitle;
100
-        $this->sTitle = '';
101
-        return $sTitle;
102
-    }
97
+private function getTitle(): string
98
+{
99
+$sTitle = $this->sTitle;
100
+$this->sTitle = '';
101
+return $sTitle;
102
+}
103 103
 
104
-    /**
104
+/**
105 105
      * Print an alert message.
106 106
      *
107 107
      * @param string $sType     The type of the message
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @return array
112 112
      */
113
-    private function alert(string $sType, string $sMessage, array $aArgs): array
114
-    {
115
-        return [
116
-            'lib' => $this->getLibrary() ?:
117
-                ($this->xRegistry?->getAlertLibrary()->getName() ?? ''),
118
-            'message' => [
119
-                'type' => $sType,
120
-                'title' => $this->getTitle(),
121
-                'phrase' => $this->phrase($sMessage, $aArgs),
122
-            ],
123
-        ];
124
-    }
125
-
126
-    /**
113
+private function alert(string $sType, string $sMessage, array $aArgs): array
114
+{
115
+return [
116
+'lib' => $this->getLibrary() ?:
117
+    ($this->xRegistry?->getAlertLibrary()->getName() ?? ''),
118
+'message' => [
119
+    'type' => $sType,
120
+    'title' => $this->getTitle(),
121
+    'phrase' => $this->phrase($sMessage, $aArgs),
122
+],
123
+];
124
+}
125
+
126
+/**
127 127
      * Show a success message.
128 128
      *
129 129
      * @param string $sMessage  The text of the message
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @return array
133 133
      */
134
-    public function success(string $sMessage, array $aArgs = []): array
135
-    {
136
-        return $this->alert('success', $sMessage, $aArgs);
137
-    }
134
+public function success(string $sMessage, array $aArgs = []): array
135
+{
136
+return $this->alert('success', $sMessage, $aArgs);
137
+}
138 138
 
139
-    /**
139
+/**
140 140
      * Show an information message.
141 141
      *
142 142
      * @param string $sMessage  The text of the message
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @return array
146 146
      */
147
-    public function info(string $sMessage, array $aArgs = []): array
148
-    {
149
-        return $this->alert('info', $sMessage, $aArgs);
150
-    }
147
+public function info(string $sMessage, array $aArgs = []): array
148
+{
149
+return $this->alert('info', $sMessage, $aArgs);
150
+}
151 151
 
152
-    /**
152
+/**
153 153
      * Show a warning message.
154 154
      *
155 155
      * @param string $sMessage  The text of the message
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return array
159 159
      */
160
-    public function warning(string $sMessage, array $aArgs = []): array
161
-    {
162
-        return $this->alert('warning', $sMessage, $aArgs);
163
-    }
160
+public function warning(string $sMessage, array $aArgs = []): array
161
+{
162
+return $this->alert('warning', $sMessage, $aArgs);
163
+}
164 164
 
165
-    /**
165
+/**
166 166
      * Show an error message.
167 167
      *
168 168
      * @param string $sMessage  The text of the message
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
      *
171 171
      * @return array
172 172
      */
173
-    public function error(string $sMessage, array $aArgs = []): array
174
-    {
175
-        return $this->alert('error', $sMessage, $aArgs);
176
-    }
173
+public function error(string $sMessage, array $aArgs = []): array
174
+{
175
+return $this->alert('error', $sMessage, $aArgs);
176
+}
177 177
 
178
-    /**
178
+/**
179 179
      * Show a modal dialog.
180 180
      *
181 181
      * @param string $sTitle The title of the dialog
@@ -194,34 +194,34 @@  discard block
 block discarded – undo
194 194
      *
195 195
      * @return array
196 196
      */
197
-    public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []): array
198
-    {
199
-        return [
200
-            'lib' => $this->getLibrary() ?:
201
-                ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
202
-            'dialog' => [
203
-                'title' => $sTitle,
204
-                'content' => $sContent,
205
-                'buttons' => $aButtons,
206
-                'options' => $aOptions,
207
-            ],
208
-        ];
209
-    }
210
-
211
-    /**
197
+public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []): array
198
+{
199
+return [
200
+'lib' => $this->getLibrary() ?:
201
+    ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
202
+'dialog' => [
203
+    'title' => $sTitle,
204
+    'content' => $sContent,
205
+    'buttons' => $aButtons,
206
+    'options' => $aOptions,
207
+],
208
+];
209
+}
210
+
211
+/**
212 212
      * Hide the modal dialog.
213 213
      *
214 214
      * @return array
215 215
      */
216
-    public function hide(): array
217
-    {
218
-        return [
219
-            'lib' => $this->getLibrary() ?:
220
-                ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
221
-        ];
222
-    }
216
+public function hide(): array
217
+{
218
+return [
219
+'lib' => $this->getLibrary() ?:
220
+    ($this->xRegistry?->getModalLibrary()->getName() ?? ''),
221
+];
222
+}
223 223
 
224
-    /**
224
+/**
225 225
      * Add a confirm question to a function call.
226 226
      *
227 227
      * @param string $sQuestion
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @return array
231 231
      */
232
-    public function confirm(string $sQuestion, array $aArgs = []): array
233
-    {
234
-        return [
235
-            'lib' => $this->getLibrary() ?:
236
-                ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''),
237
-            'question' => [
238
-                'title' => $this->getTitle(),
239
-                'phrase' => $this->phrase($sQuestion, $aArgs),
240
-            ],
241
-        ];
242
-    }
232
+public function confirm(string $sQuestion, array $aArgs = []): array
233
+{
234
+return [
235
+'lib' => $this->getLibrary() ?:
236
+    ($this->xRegistry?->getConfirmLibrary()->getName() ?? ''),
237
+'question' => [
238
+    'title' => $this->getTitle(),
239
+    'phrase' => $this->phrase($sQuestion, $aArgs),
240
+],
241
+];
242
+}
243 243
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Pagination/Paginator.php 2 patches
Spacing   +17 added lines, -20 removed lines patch added patch discarded remove patch
@@ -128,9 +128,8 @@  discard block
 block discarded – undo
128 128
      */
129 129
     private function updatePagesCount(): Paginator
130 130
     {
131
-        $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 :
132
-            (int)ceil($this->nItemsCount / $this->nItemsPerPage));
133
-        if($this->nPageNumber > $this->nPagesCount)
131
+        $this->nPagesCount = ($this->nItemsPerPage === 0 ? 0 : (int)ceil($this->nItemsCount / $this->nItemsPerPage));
132
+        if ($this->nPageNumber > $this->nPagesCount)
134 133
         {
135 134
             $this->nPageNumber = $this->nPagesCount;
136 135
         }
@@ -184,8 +183,7 @@  discard block
 block discarded – undo
184 183
     protected function getPrevPage(): Page
185 184
     {
186 185
         return $this->nPageNumber <= 1 ?
187
-            new Page('disabled', $this->sPreviousText, 0) :
188
-            new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1);
186
+            new Page('disabled', $this->sPreviousText, 0) : new Page('enabled', $this->sPreviousText, $this->nPageNumber - 1);
189 187
     }
190 188
 
191 189
     /**
@@ -196,8 +194,7 @@  discard block
 block discarded – undo
196 194
     protected function getNextPage(): Page
197 195
     {
198 196
         return $this->nPageNumber >= $this->nPagesCount ?
199
-            new Page('disabled', $this->sNextText, 0) :
200
-            new Page('enabled', $this->sNextText, $this->nPageNumber + 1);
197
+            new Page('disabled', $this->sNextText, 0) : new Page('enabled', $this->sNextText, $this->nPageNumber + 1);
201 198
     }
202 199
 
203 200
     /**
@@ -209,7 +206,7 @@  discard block
 block discarded – undo
209 206
      */
210 207
     protected function getPage(int $nNumber): Page
211 208
     {
212
-        if($nNumber < 1)
209
+        if ($nNumber < 1)
213 210
         {
214 211
             return new Page('disabled', $this->sEllipsysText, 0);
215 212
         }
@@ -228,9 +225,9 @@  discard block
 block discarded – undo
228 225
     {
229 226
         $aPageNumbers = [];
230 227
 
231
-        if($this->nPagesCount <= $this->nMaxPages)
228
+        if ($this->nPagesCount <= $this->nMaxPages)
232 229
         {
233
-            for($i = 0; $i < $this->nPagesCount; $i++)
230
+            for ($i = 0; $i < $this->nPagesCount; $i++)
234 231
             {
235 232
                 $aPageNumbers[] = $i + 1;
236 233
             }
@@ -243,7 +240,7 @@  discard block
 block discarded – undo
243 240
 
244 241
         $nSlidingStart = 1;
245 242
         $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nPageNumber;
246
-        if($nSlidingEndOffset < 0)
243
+        if ($nSlidingEndOffset < 0)
247 244
         {
248 245
             $nSlidingStart = $this->nPageNumber - $nNumAdjacents;
249 246
             $nSlidingEndOffset = 0;
@@ -251,23 +248,23 @@  discard block
 block discarded – undo
251 248
 
252 249
         $nSlidingEnd = $this->nPagesCount;
253 250
         $nSlidingStartOffset = $this->nPageNumber + $nNumAdjacents + 2 - $this->nPagesCount;
254
-        if($nSlidingStartOffset < 0)
251
+        if ($nSlidingStartOffset < 0)
255 252
         {
256 253
             $nSlidingEnd = $this->nPageNumber + $nNumAdjacents;
257 254
             $nSlidingStartOffset = 0;
258 255
         }
259 256
 
260 257
         // Build the list of page numbers.
261
-        if($nSlidingStart > 1)
258
+        if ($nSlidingStart > 1)
262 259
         {
263 260
             $aPageNumbers[] = 1;
264 261
             $aPageNumbers[] = 0; // Ellipsys;
265 262
         }
266
-        for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++)
263
+        for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++)
267 264
         {
268 265
             $aPageNumbers[] = $i;
269 266
         }
270
-        if($nSlidingEnd < $this->nPagesCount)
267
+        if ($nSlidingEnd < $this->nPagesCount)
271 268
         {
272 269
             $aPageNumbers[] = 0; // Ellipsys;
273 270
             $aPageNumbers[] = $this->nPagesCount;
@@ -293,7 +290,7 @@  discard block
 block discarded – undo
293 290
      */
294 291
     public function pages(): array
295 292
     {
296
-        if($this->nPagesCount < 2)
293
+        if ($this->nPagesCount < 2)
297 294
         {
298 295
             return [];
299 296
         }
@@ -344,7 +341,7 @@  discard block
 block discarded – undo
344 341
     private function renderLinks(): string
345 342
     {
346 343
         $aPages = $this->pages();
347
-        if(count($aPages) === 0)
344
+        if (count($aPages) === 0)
348 345
         {
349 346
             return '';
350 347
         }
@@ -365,7 +362,7 @@  discard block
 block discarded – undo
365 362
     {
366 363
         $sHtml = $this->renderLinks();
367 364
         // The HTML code must always be displayed, even if it is empty.
368
-        if(is_a($this->xPlugin->response(), Response::class))
365
+        if (is_a($this->xPlugin->response(), Response::class))
369 366
         {
370 367
             /** @var Response */
371 368
             $xResponse = $this->xPlugin->response();
@@ -388,13 +385,13 @@  discard block
 block discarded – undo
388 385
      */
389 386
     public function render(JsExpr $xCall, string $sWrapperId = ''): void
390 387
     {
391
-        if(($xFunc = $xCall->func()) === null)
388
+        if (($xFunc = $xCall->func()) === null)
392 389
         {
393 390
             return;
394 391
         }
395 392
 
396 393
         $aParams = $this->showLinks(trim($sWrapperId));
397
-        if($aParams !== null)
394
+        if ($aParams !== null)
398 395
         {
399 396
             // Set click handlers on the pagination links
400 397
             $aParams['func'] = $xFunc->withPage()->jsonSerialize();
Please login to merge, or discard this 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 = '&laquo;';
90
+protected $sPreviousText = '&laquo;';
91 91
 
92
-    /**
92
+/**
93 93
      * @var string
94 94
      */
95
-    protected $sNextText = '&raquo;';
95
+protected $sNextText = '&raquo;';
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.