Passed
Push — main ( 238af9...5ca287 )
by Thierry
20:54 queued 15:16
created
jaxon-core/src/Request/TargetInterface.php 1 patch
Switch Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 
5 5
 interface TargetInterface
6 6
 {
7
-    /**
7
+/**
8 8
      * The target method name.
9 9
      *
10 10
      * @return string
11 11
      */
12
-    public function method(): string;
12
+public function method(): string;
13 13
 
14
-    /**
14
+/**
15 15
      * The target method args.
16 16
      *
17 17
      * @return array
18 18
      */
19
-    public function args(): array;
19
+public function args(): array;
20 20
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Validator.php 1 patch
Switch Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -29,73 +29,73 @@
 block discarded – undo
29 29
 
30 30
 class Validator
31 31
 {
32
-    /**
32
+/**
33 33
      * The config manager
34 34
      *
35 35
      * @var ConfigManager
36 36
      */
37
-    protected $xConfigManager;
37
+protected $xConfigManager;
38 38
 
39
-    /**
39
+/**
40 40
      * The translator
41 41
      *
42 42
      * @var Translator
43 43
      */
44
-    protected $xTranslator;
44
+protected $xTranslator;
45 45
 
46
-    public function __construct(ConfigManager $xConfigManager, Translator $xTranslator)
47
-    {
48
-        // Set the config manager
49
-        $this->xConfigManager = $xConfigManager;
50
-        // Set the translator
51
-        $this->xTranslator = $xTranslator;
52
-    }
46
+public function __construct(ConfigManager $xConfigManager, Translator $xTranslator)
47
+{
48
+// Set the config manager
49
+$this->xConfigManager = $xConfigManager;
50
+// Set the translator
51
+$this->xTranslator = $xTranslator;
52
+}
53 53
 
54
-    /**
54
+/**
55 55
      * Validate a function name
56 56
      *
57 57
      * @param string $sName    The function name
58 58
      *
59 59
      * @return bool
60 60
      */
61
-    public function validateFunction(string $sName): bool
62
-    {
63
-        return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0;
64
-    }
61
+public function validateFunction(string $sName): bool
62
+{
63
+return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0;
64
+}
65 65
 
66
-    /**
66
+/**
67 67
      * Validate a class name
68 68
      *
69 69
      * @param string $sName    The class name
70 70
      *
71 71
      * @return bool
72 72
      */
73
-    public function validateJsObject(string $sName): bool
74
-    {
75
-        return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0;
76
-    }
73
+public function validateJsObject(string $sName): bool
74
+{
75
+return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0;
76
+}
77 77
 
78
-    /**
78
+/**
79 79
      * Validate a class name
80 80
      *
81 81
      * @param string $sName    The class name
82 82
      *
83 83
      * @return bool
84 84
      */
85
-    public function validateClass(string $sName): bool
86
-    {
87
-        return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0;
88
-    }
85
+public function validateClass(string $sName): bool
86
+{
87
+return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0;
88
+}
89 89
 
90
-    /**
90
+/**
91 91
      * Validate a method name
92 92
      *
93 93
      * @param string $sName    The function name
94 94
      *
95 95
      * @return bool
96 96
      */
97
-    public function validateMethod(string $sName): bool
98
-    {
99
-        return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0;
100
-    }
97
+public function validateMethod(string $sName): bool
98
+{
99
+return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0;
100
+}
101 101
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrAjaxMiddleware.php 2 patches
Switch Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,54 +25,54 @@
 block discarded – undo
25 25
 
26 26
 class PsrAjaxMiddleware implements MiddlewareInterface
27 27
 {
28
-    /**
28
+/**
29 29
      * @var Container
30 30
      */
31
-    private $di;
31
+private $di;
32 32
 
33
-    /**
33
+/**
34 34
      * @var RequestHandler
35 35
      */
36
-    private $xRequestHandler;
36
+private $xRequestHandler;
37 37
 
38
-    /**
38
+/**
39 39
      * @var ResponseManager
40 40
      */
41
-    private $xResponseManager;
41
+private $xResponseManager;
42 42
 
43
-    /**
43
+/**
44 44
      * The constructor
45 45
      *
46 46
      * @param Container $di
47 47
      * @param RequestHandler $xRequestHandler
48 48
      * @param ResponseManager $xResponseManager
49 49
      */
50
-    public function __construct(Container $di, RequestHandler $xRequestHandler, ResponseManager $xResponseManager)
51
-    {
52
-        $this->di = $di;
53
-        $this->xRequestHandler = $xRequestHandler;
54
-        $this->xResponseManager = $xResponseManager;
55
-    }
50
+public function __construct(Container $di, RequestHandler $xRequestHandler, ResponseManager $xResponseManager)
51
+{
52
+$this->di = $di;
53
+$this->xRequestHandler = $xRequestHandler;
54
+$this->xResponseManager = $xResponseManager;
55
+}
56 56
 
57
-    /**
57
+/**
58 58
      * @inheritDoc
59 59
      * @throws RequestException
60 60
      */
61
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
62
-    {
63
-        // Save the request in the container. This will override the default request,
64
-        // and the other classes will get this request from there.
65
-        $this->di->val(ServerRequestInterface::class, $request);
61
+public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
62
+{
63
+// Save the request in the container. This will override the default request,
64
+// and the other classes will get this request from there.
65
+$this->di->val(ServerRequestInterface::class, $request);
66 66
 
67
-        if(!$this->xRequestHandler->canProcessRequest())
68
-        {
69
-            // Unable to find a plugin to process the request
70
-            return $handler->handle($request);
71
-        }
67
+if(!$this->xRequestHandler->canProcessRequest())
68
+{
69
+// Unable to find a plugin to process the request
70
+return $handler->handle($request);
71
+}
72 72
 
73
-        // Process the request
74
-        $this->xRequestHandler->processRequest();
75
-        // Return a Psr7 response
76
-        return $this->xResponseManager->getResponse()->toPsr();
77
-    }
73
+// Process the request
74
+$this->xRequestHandler->processRequest();
75
+// Return a Psr7 response
76
+return $this->xResponseManager->getResponse()->toPsr();
77
+}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         // and the other classes will get this request from there.
65 65
         $this->di->val(ServerRequestInterface::class, $request);
66 66
 
67
-        if(!$this->xRequestHandler->canProcessRequest())
67
+        if (!$this->xRequestHandler->canProcessRequest())
68 68
         {
69 69
             // Unable to find a plugin to process the request
70 70
             return $handler->handle($request);
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrConfigMiddleware.php 1 patch
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,37 +23,37 @@
 block discarded – undo
23 23
 
24 24
 class PsrConfigMiddleware implements MiddlewareInterface
25 25
 {
26
-    /**
26
+/**
27 27
      * @var Container
28 28
      */
29
-    protected $di;
29
+protected $di;
30 30
 
31
-    /**
31
+/**
32 32
      * @var string
33 33
      */
34
-    protected $sConfigFile;
34
+protected $sConfigFile;
35 35
 
36
-    /**
36
+/**
37 37
      * The constructor
38 38
      *
39 39
      * @param Container $di
40 40
      * @param string $sConfigFile
41 41
      */
42
-    public function __construct(Container $di, string $sConfigFile)
43
-    {
44
-        $this->di = $di;
45
-        $this->sConfigFile = $sConfigFile;
46
-    }
42
+public function __construct(Container $di, string $sConfigFile)
43
+{
44
+$this->di = $di;
45
+$this->sConfigFile = $sConfigFile;
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * @inheritDoc
50 50
      * @throws SetupException
51 51
      */
52
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
53
-    {
54
-        // Load the config
55
-        $this->di->getApp()->setup($this->sConfigFile);
56
-        // Next
57
-        return $handler->handle($request);
58
-    }
52
+public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
53
+{
54
+// Load the config
55
+$this->di->getApp()->setup($this->sConfigFile);
56
+// Next
57
+return $handler->handle($request);
58
+}
59 59
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrRequestHandler.php 2 patches
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 
26 26
 class PsrRequestHandler implements RequestHandlerInterface
27 27
 {
28
-    /**
28
+/**
29 29
      * @var Container
30 30
      */
31
-    private $di;
31
+private $di;
32 32
 
33
-    /**
33
+/**
34 34
      * @var RequestHandler
35 35
      */
36
-    private $xRequestHandler;
36
+private $xRequestHandler;
37 37
 
38
-    /**
38
+/**
39 39
      * @var ResponseManager
40 40
      */
41
-    private $xResponseManager;
41
+private $xResponseManager;
42 42
 
43
-    /**
43
+/**
44 44
      * @var Translator
45 45
      */
46
-    private $xTranslator;
46
+private $xTranslator;
47 47
 
48
-    /**
48
+/**
49 49
      * The constructor
50 50
      *
51 51
      * @param Container $di
@@ -53,34 +53,34 @@  discard block
 block discarded – undo
53 53
      * @param ResponseManager $xResponseManager
54 54
      * @param Translator $xTranslator
55 55
      */
56
-    public function __construct(Container $di, RequestHandler $xRequestHandler,
57
-        ResponseManager $xResponseManager, Translator $xTranslator)
58
-    {
59
-        $this->di = $di;
60
-        $this->xRequestHandler = $xRequestHandler;
61
-        $this->xResponseManager = $xResponseManager;
62
-        $this->xTranslator = $xTranslator;
63
-    }
56
+public function __construct(Container $di, RequestHandler $xRequestHandler,
57
+ResponseManager $xResponseManager, Translator $xTranslator)
58
+{
59
+$this->di = $di;
60
+$this->xRequestHandler = $xRequestHandler;
61
+$this->xResponseManager = $xResponseManager;
62
+$this->xTranslator = $xTranslator;
63
+}
64 64
 
65
-    /**
65
+/**
66 66
      * @inheritDoc
67 67
      * @throws RequestException
68 68
      */
69
-    public function handle(ServerRequestInterface $request): ResponseInterface
70
-    {
71
-        // Save the request in the container. This will override the default request,
72
-        // and the other classes will get this request from there.
73
-        $this->di->val(ServerRequestInterface::class, $request);
69
+public function handle(ServerRequestInterface $request): ResponseInterface
70
+{
71
+// Save the request in the container. This will override the default request,
72
+// and the other classes will get this request from there.
73
+$this->di->val(ServerRequestInterface::class, $request);
74 74
 
75
-        if(!$this->xRequestHandler->canProcessRequest())
76
-        {
77
-            // Unable to find a plugin to process the request
78
-            throw new RequestException($this->xTranslator->trans('errors.request.plugin'));
79
-        }
75
+if(!$this->xRequestHandler->canProcessRequest())
76
+{
77
+// Unable to find a plugin to process the request
78
+throw new RequestException($this->xTranslator->trans('errors.request.plugin'));
79
+}
80 80
 
81
-        // Process the request
82
-        $this->xRequestHandler->processRequest();
83
-        // Return a Psr7 response
84
-        return $this->xResponseManager->getResponse()->toPsr();
85
-    }
81
+// Process the request
82
+$this->xRequestHandler->processRequest();
83
+// Return a Psr7 response
84
+return $this->xResponseManager->getResponse()->toPsr();
85
+}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
         // and the other classes will get this request from there.
73 73
         $this->di->val(ServerRequestInterface::class, $request);
74 74
 
75
-        if(!$this->xRequestHandler->canProcessRequest())
75
+        if (!$this->xRequestHandler->canProcessRequest())
76 76
         {
77 77
             // Unable to find a plugin to process the request
78 78
             throw new RequestException($this->xTranslator->trans('errors.request.plugin'));
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrFactory.php 1 patch
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -22,50 +22,50 @@  discard block
 block discarded – undo
22 22
 
23 23
 class PsrFactory
24 24
 {
25
-    /**
25
+/**
26 26
      * The container
27 27
      *
28 28
      * @var Container
29 29
      */
30
-    protected $di;
30
+protected $di;
31 31
 
32
-    /**
32
+/**
33 33
      * The constructor
34 34
      *
35 35
      * @param Container $di
36 36
      */
37
-    public function __construct(Container $di)
38
-    {
39
-        $this->di = $di;
40
-    }
37
+public function __construct(Container $di)
38
+{
39
+$this->di = $di;
40
+}
41 41
 
42
-    /**
42
+/**
43 43
      * Set the logger
44 44
      *
45 45
      * @param LoggerInterface $xLogger
46 46
      *
47 47
      * @return $this
48 48
      */
49
-    public function logger(LoggerInterface $xLogger): PsrFactory
50
-    {
51
-        $this->di->setLogger($xLogger);
52
-        return $this;
53
-    }
49
+public function logger(LoggerInterface $xLogger): PsrFactory
50
+{
51
+$this->di->setLogger($xLogger);
52
+return $this;
53
+}
54 54
 
55
-    /**
55
+/**
56 56
      * Set the container
57 57
      *
58 58
      * @param ContainerInterface $xContainer
59 59
      *
60 60
      * @return $this
61 61
      */
62
-    public function container(ContainerInterface $xContainer): PsrFactory
63
-    {
64
-        $this->di->setContainer($xContainer);
65
-        return $this;
66
-    }
62
+public function container(ContainerInterface $xContainer): PsrFactory
63
+{
64
+$this->di->setContainer($xContainer);
65
+return $this;
66
+}
67 67
 
68
-    /**
68
+/**
69 69
      * Add a view renderer with an id
70 70
      *
71 71
      * @param string $sRenderer    The renderer name
@@ -74,41 +74,41 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return $this
76 76
      */
77
-    public function view(string $sRenderer, string $sExtension, Closure $xClosure): PsrFactory
78
-    {
79
-        $this->di->getViewRenderer()->setDefaultRenderer($sRenderer, $sExtension, $xClosure);
80
-        return $this;
81
-    }
77
+public function view(string $sRenderer, string $sExtension, Closure $xClosure): PsrFactory
78
+{
79
+$this->di->getViewRenderer()->setDefaultRenderer($sRenderer, $sExtension, $xClosure);
80
+return $this;
81
+}
82 82
 
83
-    /**
83
+/**
84 84
      * Get the Jaxon ajax PSR request handler
85 85
      *
86 86
      * @return PsrRequestHandler
87 87
      */
88
-    public function handler(): PsrRequestHandler
89
-    {
90
-        return $this->di->getPsrRequestHandler();
91
-    }
88
+public function handler(): PsrRequestHandler
89
+{
90
+return $this->di->getPsrRequestHandler();
91
+}
92 92
 
93
-    /**
93
+/**
94 94
      * Get the Jaxon config PSR middleware
95 95
      *
96 96
      * @param string $sConfigFile
97 97
      *
98 98
      * @return PsrConfigMiddleware
99 99
      */
100
-    public function config(string $sConfigFile): PsrConfigMiddleware
101
-    {
102
-        return $this->di->getPsrConfigMiddleware($sConfigFile);
103
-    }
100
+public function config(string $sConfigFile): PsrConfigMiddleware
101
+{
102
+return $this->di->getPsrConfigMiddleware($sConfigFile);
103
+}
104 104
 
105
-    /**
105
+/**
106 106
      * Get the Jaxon ajax PSR middleware
107 107
      *
108 108
      * @return PsrAjaxMiddleware
109 109
      */
110
-    public function ajax(): PsrAjaxMiddleware
111
-    {
112
-        return $this->di->getPsrAjaxMiddleware();
113
-    }
110
+public function ajax(): PsrAjaxMiddleware
111
+{
112
+return $this->di->getPsrAjaxMiddleware();
113
+}
114 114
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/CallbackManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function popBootCallbacks(): array
100 100
     {
101
-        if(empty($this->aBootCallbacks))
101
+        if (empty($this->aBootCallbacks))
102 102
         {
103 103
             return [];
104 104
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     private function getExceptionCallbacks(Exception $xException): array
118 118
     {
119 119
         $aExceptionCallbacks = [];
120
-        foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks)
120
+        foreach ($this->aExceptionCallbacks as $sExClass => $aCallbacks)
121 121
         {
122
-            if(is_a($xException, $sExClass))
122
+            if (is_a($xException, $sExClass))
123 123
             {
124 124
                 $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks);
125 125
             }
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function error(callable $xCallable, string $sExClass = ''): CallbackManager
191 191
     {
192
-        if($sExClass === '' || $sExClass === Exception::class)
192
+        if ($sExClass === '' || $sExClass === Exception::class)
193 193
         {
194 194
             $this->aErrorCallbacks[] = $xCallable;
195 195
             return $this;
196 196
         }
197 197
         // Callback for a given exception class
198
-        if(isset($this->aExceptionCallbacks[$sExClass]))
198
+        if (isset($this->aExceptionCallbacks[$sExClass]))
199 199
         {
200 200
             $this->aExceptionCallbacks[$sExClass][] = $xCallable;
201 201
             return $this;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     private function executeCallbacks(array $aCallbacks, array $aParameters): void
238 238
     {
239
-        foreach($aCallbacks as $xCallback)
239
+        foreach ($aCallbacks as $xCallback)
240 240
         {
241 241
             $this->executeCallback($xCallback, $aParameters);
242 242
         }
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     public function onBefore(Target $xTarget, bool &$bEndRequest): void
267 267
     {
268 268
         // Call the user defined callback
269
-        foreach($this->aBeforeCallbacks as $xCallback)
269
+        foreach ($this->aBeforeCallbacks as $xCallback)
270 270
         {
271 271
             $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]);
272
-            if($bEndRequest)
272
+            if ($bEndRequest)
273 273
             {
274 274
                 return;
275 275
             }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $aExceptionCallbacks = $this->getExceptionCallbacks($xException);
318 318
         $this->executeCallbacks($aExceptionCallbacks, [$xException]);
319
-        if(count($aExceptionCallbacks) > 0)
319
+        if (count($aExceptionCallbacks) > 0)
320 320
         {
321 321
             // Do not throw the exception if a custom handler is defined
322 322
             return;
Please login to merge, or discard this patch.
Switch Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -26,144 +26,144 @@  discard block
 block discarded – undo
26 26
 
27 27
 class CallbackManager
28 28
 {
29
-    /**
29
+/**
30 30
      * The callbacks to run after booting the library
31 31
      *
32 32
      * @var callable[]
33 33
      */
34
-    protected $aBootCallbacks = [];
34
+protected $aBootCallbacks = [];
35 35
 
36
-    /**
36
+/**
37 37
      * The callbacks to run before processing the request
38 38
      *
39 39
      * @var callable[]
40 40
      */
41
-    protected $aBeforeCallbacks = [];
41
+protected $aBeforeCallbacks = [];
42 42
 
43
-    /**
43
+/**
44 44
      * The callbacks to run after processing the request
45 45
      *
46 46
      * @var callable[]
47 47
      */
48
-    protected $aAfterCallbacks = [];
48
+protected $aAfterCallbacks = [];
49 49
 
50
-    /**
50
+/**
51 51
      * The callbacks to run in case of invalid request
52 52
      *
53 53
      * @var callable[]
54 54
      */
55
-    protected $aInvalidCallbacks = [];
55
+protected $aInvalidCallbacks = [];
56 56
 
57
-    /**
57
+/**
58 58
      * The callbacks to run in case of error
59 59
      *
60 60
      * @var callable[]
61 61
      */
62
-    protected $aErrorCallbacks = [];
62
+protected $aErrorCallbacks = [];
63 63
 
64
-    /**
64
+/**
65 65
      * The callbacks to run in case of exception
66 66
      *
67 67
      * @var callable[][]
68 68
      */
69
-    protected $aExceptionCallbacks = [];
69
+protected $aExceptionCallbacks = [];
70 70
 
71
-    /**
71
+/**
72 72
      * The callbacks to run when a class is instanced
73 73
      *
74 74
      * @var callable[]
75 75
      */
76
-    protected $aInitCallbacks = [];
76
+protected $aInitCallbacks = [];
77 77
 
78
-    /**
78
+/**
79 79
      * Get the library booting callbacks, and reset the array.
80 80
      *
81 81
      * @return callable[]
82 82
      */
83
-    public function popBootCallbacks(): array
84
-    {
85
-        if(empty($this->aBootCallbacks))
86
-        {
87
-            return [];
88
-        }
89
-        $aCallbacks = $this->aBootCallbacks;
90
-        $this->aBootCallbacks = [];
91
-        return $aCallbacks;
92
-    }
83
+public function popBootCallbacks(): array
84
+{
85
+if(empty($this->aBootCallbacks))
86
+{
87
+return [];
88
+}
89
+$aCallbacks = $this->aBootCallbacks;
90
+$this->aBootCallbacks = [];
91
+return $aCallbacks;
92
+}
93 93
 
94
-    /**
94
+/**
95 95
      * Get the exception callbacks.
96 96
      *
97 97
      * @param Exception $xException      The exception class
98 98
      *
99 99
      * @return callable[]
100 100
      */
101
-    private function getExceptionCallbacks(Exception $xException): array
102
-    {
103
-        $aExceptionCallbacks = [];
104
-        foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks)
105
-        {
106
-            if(is_a($xException, $sExClass))
107
-            {
108
-                $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks);
109
-            }
110
-        }
111
-        return array_values($aExceptionCallbacks);
112
-    }
101
+private function getExceptionCallbacks(Exception $xException): array
102
+{
103
+$aExceptionCallbacks = [];
104
+foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks)
105
+{
106
+if(is_a($xException, $sExClass))
107
+{
108
+    $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks);
109
+}
110
+}
111
+return array_values($aExceptionCallbacks);
112
+}
113 113
 
114
-    /**
114
+/**
115 115
      * Add a library booting callback.
116 116
      *
117 117
      * @param callable $xCallable    The callback function
118 118
      *
119 119
      * @return CallbackManager
120 120
      */
121
-    public function boot(callable $xCallable): CallbackManager
122
-    {
123
-        $this->aBootCallbacks[] = $xCallable;
124
-        return $this;
125
-    }
121
+public function boot(callable $xCallable): CallbackManager
122
+{
123
+$this->aBootCallbacks[] = $xCallable;
124
+return $this;
125
+}
126 126
 
127
-    /**
127
+/**
128 128
      * Add a pre-request processing callback.
129 129
      *
130 130
      * @param callable $xCallable    The callback function
131 131
      *
132 132
      * @return CallbackManager
133 133
      */
134
-    public function before(callable $xCallable): CallbackManager
135
-    {
136
-        $this->aBeforeCallbacks[] = $xCallable;
137
-        return $this;
138
-    }
134
+public function before(callable $xCallable): CallbackManager
135
+{
136
+$this->aBeforeCallbacks[] = $xCallable;
137
+return $this;
138
+}
139 139
 
140
-    /**
140
+/**
141 141
      * Add a post-request processing callback.
142 142
      *
143 143
      * @param callable $xCallable    The callback function
144 144
      *
145 145
      * @return CallbackManager
146 146
      */
147
-    public function after(callable $xCallable): CallbackManager
148
-    {
149
-        $this->aAfterCallbacks[] = $xCallable;
150
-        return $this;
151
-    }
147
+public function after(callable $xCallable): CallbackManager
148
+{
149
+$this->aAfterCallbacks[] = $xCallable;
150
+return $this;
151
+}
152 152
 
153
-    /**
153
+/**
154 154
      * Add a invalid request callback.
155 155
      *
156 156
      * @param callable $xCallable    The callback function
157 157
      *
158 158
      * @return CallbackManager
159 159
      */
160
-    public function invalid(callable $xCallable): CallbackManager
161
-    {
162
-        $this->aInvalidCallbacks[] = $xCallable;
163
-        return $this;
164
-    }
160
+public function invalid(callable $xCallable): CallbackManager
161
+{
162
+$this->aInvalidCallbacks[] = $xCallable;
163
+return $this;
164
+}
165 165
 
166
-    /**
166
+/**
167 167
      * Add a processing error callback.
168 168
      *
169 169
      * @param callable $xCallable   The callback function
@@ -171,74 +171,74 @@  discard block
 block discarded – undo
171 171
      *
172 172
      * @return CallbackManager
173 173
      */
174
-    public function error(callable $xCallable, string $sExClass = ''): CallbackManager
175
-    {
176
-        if($sExClass === '' || $sExClass === Exception::class)
177
-        {
178
-            $this->aErrorCallbacks[] = $xCallable;
179
-            return $this;
180
-        }
181
-        // Callback for a given exception class
182
-        if(isset($this->aExceptionCallbacks[$sExClass]))
183
-        {
184
-            $this->aExceptionCallbacks[$sExClass][] = $xCallable;
185
-            return $this;
186
-        }
187
-        $this->aExceptionCallbacks[$sExClass] = [$xCallable];
188
-        return $this;
189
-    }
174
+public function error(callable $xCallable, string $sExClass = ''): CallbackManager
175
+{
176
+if($sExClass === '' || $sExClass === Exception::class)
177
+{
178
+$this->aErrorCallbacks[] = $xCallable;
179
+return $this;
180
+}
181
+// Callback for a given exception class
182
+if(isset($this->aExceptionCallbacks[$sExClass]))
183
+{
184
+$this->aExceptionCallbacks[$sExClass][] = $xCallable;
185
+return $this;
186
+}
187
+$this->aExceptionCallbacks[$sExClass] = [$xCallable];
188
+return $this;
189
+}
190 190
 
191
-    /**
191
+/**
192 192
      * Add a class initialisation callback.
193 193
      *
194 194
      * @param callable $xCallable    The callback function
195 195
      *
196 196
      * @return CallbackManager
197 197
      */
198
-    public function init(callable $xCallable): CallbackManager
199
-    {
200
-        $this->aInitCallbacks[] = $xCallable;
201
-        return $this;
202
-    }
198
+public function init(callable $xCallable): CallbackManager
199
+{
200
+$this->aInitCallbacks[] = $xCallable;
201
+return $this;
202
+}
203 203
 
204
-    /**
204
+/**
205 205
      * @param callable $xCallback
206 206
      * @param array $aParameters
207 207
      *
208 208
      * @return void
209 209
      */
210
-    private function executeCallback(callable $xCallback, array $aParameters): void
211
-    {
212
-        call_user_func_array($xCallback, $aParameters);
213
-    }
210
+private function executeCallback(callable $xCallback, array $aParameters): void
211
+{
212
+call_user_func_array($xCallback, $aParameters);
213
+}
214 214
 
215
-    /**
215
+/**
216 216
      * @param array $aCallbacks
217 217
      * @param array $aParameters
218 218
      *
219 219
      * @return void
220 220
      */
221
-    private function executeCallbacks(array $aCallbacks, array $aParameters): void
222
-    {
223
-        foreach($aCallbacks as $xCallback)
224
-        {
225
-            $this->executeCallback($xCallback, $aParameters);
226
-        }
227
-    }
221
+private function executeCallbacks(array $aCallbacks, array $aParameters): void
222
+{
223
+foreach($aCallbacks as $xCallback)
224
+{
225
+$this->executeCallback($xCallback, $aParameters);
226
+}
227
+}
228 228
 
229
-    /**
229
+/**
230 230
      * Execute the class initialisation callbacks.
231 231
      *
232 232
      * @param mixed $xComponent
233 233
      *
234 234
      * @return void
235 235
      */
236
-    public function onInit($xComponent): void
237
-    {
238
-        $this->executeCallbacks($this->aInitCallbacks, [$xComponent]);
239
-    }
236
+public function onInit($xComponent): void
237
+{
238
+$this->executeCallbacks($this->aInitCallbacks, [$xComponent]);
239
+}
240 240
 
241
-    /**
241
+/**
242 242
      * These are the pre-request processing callbacks passed to the Jaxon library.
243 243
      *
244 244
      * @param Target $xTarget
@@ -247,20 +247,20 @@  discard block
 block discarded – undo
247 247
      * @return void
248 248
      * @throws RequestException
249 249
      */
250
-    public function onBefore(Target $xTarget, bool &$bEndRequest): void
251
-    {
252
-        // Call the user defined callback
253
-        foreach($this->aBeforeCallbacks as $xCallback)
254
-        {
255
-            $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]);
256
-            if($bEndRequest)
257
-            {
258
-                return;
259
-            }
260
-        }
261
-    }
250
+public function onBefore(Target $xTarget, bool &$bEndRequest): void
251
+{
252
+// Call the user defined callback
253
+foreach($this->aBeforeCallbacks as $xCallback)
254
+{
255
+$this->executeCallback($xCallback, [$xTarget, &$bEndRequest]);
256
+if($bEndRequest)
257
+{
258
+    return;
259
+}
260
+}
261
+}
262 262
 
263
-    /**
263
+/**
264 264
      * These are the post-request processing callbacks passed to the Jaxon library.
265 265
      *
266 266
      * @param Target $xTarget
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
      * @return void
270 270
      * @throws RequestException
271 271
      */
272
-    public function onAfter(Target $xTarget, bool $bEndRequest): void
273
-    {
274
-        $this->executeCallbacks($this->aAfterCallbacks, [$xTarget, $bEndRequest]);
275
-    }
272
+public function onAfter(Target $xTarget, bool $bEndRequest): void
273
+{
274
+$this->executeCallbacks($this->aAfterCallbacks, [$xTarget, $bEndRequest]);
275
+}
276 276
 
277
-    /**
277
+/**
278 278
      * These callbacks are called whenever an invalid request is processed.
279 279
      *
280 280
      * @param RequestException $xException
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
      * @return void
283 283
      * @throws RequestException
284 284
      */
285
-    public function onInvalid(RequestException $xException): void
286
-    {
287
-        $this->executeCallbacks($this->aInvalidCallbacks, [$xException]);
288
-        throw $xException;
289
-    }
285
+public function onInvalid(RequestException $xException): void
286
+{
287
+$this->executeCallbacks($this->aInvalidCallbacks, [$xException]);
288
+throw $xException;
289
+}
290 290
 
291
-    /**
291
+/**
292 292
      * These callbacks are called whenever an invalid request is processed.
293 293
      *
294 294
      * @param Exception $xException
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
      * @return void
297 297
      * @throws Exception
298 298
      */
299
-    public function onError(Exception $xException): void
300
-    {
301
-        $aExceptionCallbacks = $this->getExceptionCallbacks($xException);
302
-        $this->executeCallbacks($aExceptionCallbacks, [$xException]);
303
-        if(count($aExceptionCallbacks) > 0)
304
-        {
305
-            // Do not throw the exception if a custom handler is defined
306
-            return;
307
-        }
299
+public function onError(Exception $xException): void
300
+{
301
+$aExceptionCallbacks = $this->getExceptionCallbacks($xException);
302
+$this->executeCallbacks($aExceptionCallbacks, [$xException]);
303
+if(count($aExceptionCallbacks) > 0)
304
+{
305
+// Do not throw the exception if a custom handler is defined
306
+return;
307
+}
308 308
 
309
-        $this->executeCallbacks($this->aErrorCallbacks, [$xException]);
310
-        throw $xException;
311
-    }
309
+$this->executeCallbacks($this->aErrorCallbacks, [$xException]);
310
+throw $xException;
311
+}
312 312
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/RequestHandler.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function canProcessRequest(): bool
62 62
     {
63 63
         // Return true if the request plugin was already found
64
-        if($this->xRequestPlugin !== null)
64
+        if ($this->xRequestPlugin !== null)
65 65
         {
66 66
             return true;
67 67
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $xRequest = $this->di->getRequest();
71 71
 
72 72
         // Find a plugin to process the request
73
-        foreach($this->xPluginManager->getRequestHandlers() as $sClassName)
73
+        foreach ($this->xPluginManager->getRequestHandlers() as $sClassName)
74 74
         {
75
-            if($sClassName::canProcessRequest($xRequest))
75
+            if ($sClassName::canProcessRequest($xRequest))
76 76
             {
77 77
                 $this->xRequestPlugin = $this->di->g($sClassName);
78 78
                 $xTarget = $this->xRequestPlugin->setTarget($xRequest);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     private function _processRequest(): void
93 93
     {
94 94
         // Process the request
95
-        if($this->xRequestPlugin !== null)
95
+        if ($this->xRequestPlugin !== null)
96 96
         {
97 97
             $this->xRequestPlugin->processRequest();
98 98
             // Process the databag
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     public function processRequest(): void
110 110
     {
111 111
         // Check if there is a plugin to process this request
112
-        if(!$this->canProcessRequest())
112
+        if (!$this->canProcessRequest())
113 113
         {
114 114
             return;
115 115
         }
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
         {
119 119
             $bEndRequest = false;
120 120
             // Handle before processing event
121
-            if($this->xRequestPlugin !== null)
121
+            if ($this->xRequestPlugin !== null)
122 122
             {
123 123
                 $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest);
124 124
             }
125
-            if($bEndRequest)
125
+            if ($bEndRequest)
126 126
             {
127 127
                 return;
128 128
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $this->_processRequest();
131 131
 
132 132
             // Handle after processing event
133
-            if($this->xRequestPlugin !== null)
133
+            if ($this->xRequestPlugin !== null)
134 134
             {
135 135
                 $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest);
136 136
             }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
         // An exception was thrown while processing the request.
139 139
         // The request missed the corresponding handler function,
140 140
         // or an error occurred while attempting to execute the handler.
141
-        catch(RequestException $e)
141
+        catch (RequestException $e)
142 142
         {
143 143
             $this->xResponseManager->error($e->getMessage());
144 144
             $this->xCallbackManager->onInvalid($e);
145 145
         }
146
-        catch(Exception $e)
146
+        catch (Exception $e)
147 147
         {
148 148
             $this->xResponseManager->error($e->getMessage());
149 149
             $this->xCallbackManager->onError($e);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -142,8 +142,7 @@
 block discarded – undo
142 142
         {
143 143
             $this->xResponseManager->error($e->getMessage());
144 144
             $this->xCallbackManager->onInvalid($e);
145
-        }
146
-        catch(Exception $e)
145
+        } catch(Exception $e)
147 146
         {
148 147
             $this->xResponseManager->error($e->getMessage());
149 148
             $this->xCallbackManager->onError($e);
Please login to merge, or discard this patch.
Switch Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 
31 31
 class RequestHandler
32 32
 {
33
-    /**
33
+/**
34 34
      * The request plugin that is able to process the current request
35 35
      *
36 36
      * @var RequestHandlerInterface
37 37
      */
38
-    private $xRequestPlugin = null;
38
+private $xRequestPlugin = null;
39 39
 
40
-    /**
40
+/**
41 41
      * The constructor
42 42
      *
43 43
      * @param Container $di
@@ -46,110 +46,110 @@  discard block
 block discarded – undo
46 46
      * @param CallbackManager $xCallbackManager
47 47
      * @param DatabagPlugin $xDatabagPlugin
48 48
      */
49
-    public function __construct(private Container $di, private PluginManager $xPluginManager,
50
-        private ResponseManager $xResponseManager, private CallbackManager $xCallbackManager,
51
-        private DatabagPlugin $xDatabagPlugin)
52
-    {}
49
+public function __construct(private Container $di, private PluginManager $xPluginManager,
50
+private ResponseManager $xResponseManager, private CallbackManager $xCallbackManager,
51
+private DatabagPlugin $xDatabagPlugin)
52
+{}
53 53
 
54
-    /**
54
+/**
55 55
      * Check if the current request can be processed
56 56
      *
57 57
      * Calls each of the request plugins and determines if the current request can be processed by one of them.
58 58
      *
59 59
      * @return bool
60 60
      */
61
-    public function canProcessRequest(): bool
62
-    {
63
-        // Return true if the request plugin was already found
64
-        if($this->xRequestPlugin !== null)
65
-        {
66
-            return true;
67
-        }
61
+public function canProcessRequest(): bool
62
+{
63
+// Return true if the request plugin was already found
64
+if($this->xRequestPlugin !== null)
65
+{
66
+return true;
67
+}
68 68
 
69
-        // The HTTP request
70
-        $xRequest = $this->di->getRequest();
69
+// The HTTP request
70
+$xRequest = $this->di->getRequest();
71 71
 
72
-        // Find a plugin to process the request
73
-        foreach($this->xPluginManager->getRequestHandlers() as $sClassName)
74
-        {
75
-            if($sClassName::canProcessRequest($xRequest))
76
-            {
77
-                $this->xRequestPlugin = $this->di->g($sClassName);
78
-                $xTarget = $this->xRequestPlugin->setTarget($xRequest);
79
-                $xTarget->setMethodArgs($this->di->getRequestArguments());
80
-                return true;
81
-            }
82
-        }
83
-        return false;
84
-    }
72
+// Find a plugin to process the request
73
+foreach($this->xPluginManager->getRequestHandlers() as $sClassName)
74
+{
75
+if($sClassName::canProcessRequest($xRequest))
76
+{
77
+    $this->xRequestPlugin = $this->di->g($sClassName);
78
+    $xTarget = $this->xRequestPlugin->setTarget($xRequest);
79
+    $xTarget->setMethodArgs($this->di->getRequestArguments());
80
+    return true;
81
+}
82
+}
83
+return false;
84
+}
85 85
 
86
-    /**
86
+/**
87 87
      * Process the current request and handle errors and exceptions.
88 88
      *
89 89
      * @return void
90 90
      * @throws RequestException
91 91
      */
92
-    private function _processRequest(): void
93
-    {
94
-        // Process the request
95
-        if($this->xRequestPlugin !== null)
96
-        {
97
-            $this->xRequestPlugin->processRequest();
98
-            // Process the databag
99
-            $this->xDatabagPlugin->writeCommand();
100
-        }
101
-    }
92
+private function _processRequest(): void
93
+{
94
+// Process the request
95
+if($this->xRequestPlugin !== null)
96
+{
97
+$this->xRequestPlugin->processRequest();
98
+// Process the databag
99
+$this->xDatabagPlugin->writeCommand();
100
+}
101
+}
102 102
 
103
-    /**
103
+/**
104 104
      * Process the current request.
105 105
      *
106 106
      * @return void
107 107
      * @throws RequestException
108 108
      */
109
-    public function processRequest(): void
110
-    {
111
-        // Check if there is a plugin to process this request
112
-        if(!$this->canProcessRequest())
113
-        {
114
-            return;
115
-        }
109
+public function processRequest(): void
110
+{
111
+// Check if there is a plugin to process this request
112
+if(!$this->canProcessRequest())
113
+{
114
+return;
115
+}
116 116
 
117
-        try
118
-        {
119
-            $bEndRequest = false;
120
-            // Handle before processing event
121
-            if($this->xRequestPlugin !== null)
122
-            {
123
-                $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest);
124
-            }
125
-            if($bEndRequest)
126
-            {
127
-                return;
128
-            }
117
+try
118
+{
119
+$bEndRequest = false;
120
+// Handle before processing event
121
+if($this->xRequestPlugin !== null)
122
+{
123
+    $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest);
124
+}
125
+if($bEndRequest)
126
+{
127
+    return;
128
+}
129 129
 
130
-            $this->_processRequest();
130
+$this->_processRequest();
131 131
 
132
-            // Handle after processing event
133
-            if($this->xRequestPlugin !== null)
134
-            {
135
-                $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest);
136
-            }
137
-        }
138
-        // An exception was thrown while processing the request.
139
-        // The request missed the corresponding handler function,
140
-        // or an error occurred while attempting to execute the handler.
141
-        catch(RequestException $e)
142
-        {
143
-            $this->xResponseManager->error($e->getMessage());
144
-            $this->xCallbackManager->onInvalid($e);
145
-        }
146
-        catch(Exception $e)
147
-        {
148
-            $this->xResponseManager->error($e->getMessage());
149
-            $this->xCallbackManager->onError($e);
150
-        }
132
+// Handle after processing event
133
+if($this->xRequestPlugin !== null)
134
+{
135
+    $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest);
136
+}
137
+}
138
+// An exception was thrown while processing the request.
139
+// The request missed the corresponding handler function,
140
+// or an error occurred while attempting to execute the handler.
141
+catch(RequestException $e)
142
+{
143
+$this->xResponseManager->error($e->getMessage());
144
+$this->xCallbackManager->onInvalid($e);
145
+}
146
+catch(Exception $e)
147
+{
148
+$this->xResponseManager->error($e->getMessage());
149
+$this->xCallbackManager->onError($e);
150
+}
151 151
 
152
-        // Print the debug messages
153
-        $this->xResponseManager->printDebug();
154
-    }
152
+// Print the debug messages
153
+$this->xResponseManager->printDebug();
154
+}
155 155
 }
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/ParameterReader.php 2 patches
Switch Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 class ParameterReader
42 42
 {
43
-    /**
43
+/**
44 44
      * The constructor
45 45
      *
46 46
      * @param Container $di
@@ -48,28 +48,28 @@  discard block
 block discarded – undo
48 48
      * @param ConfigManager $xConfigManager
49 49
      * @param UriDetector $xUriDetector
50 50
      */
51
-    public function __construct(private Container $di, private Translator $xTranslator,
52
-        private ConfigManager $xConfigManager, private UriDetector $xUriDetector)
53
-    {}
51
+public function __construct(private Container $di, private Translator $xTranslator,
52
+private ConfigManager $xConfigManager, private UriDetector $xUriDetector)
53
+{}
54 54
 
55
-    /**
55
+/**
56 56
      * Decode input data.
57 57
      *
58 58
      * @param string $sStr
59 59
      *
60 60
      * @return string
61 61
      */
62
-    private function decodeStr(string $sStr): string
63
-    {
64
-        $aServerParams = $this->di->getServerParams();
65
-        $sContentType = $aServerParams['CONTENT_TYPE'] ?? $aServerParams['HTTP_CONTENT_TYPE'] ?? '';
66
-        $sType = 'multipart/form-data';
67
-        // Parameters are url encoded when uploading files
68
-        return strncmp($sContentType, $sType, strlen($sType)) !== 0 ?
69
-            $sStr : urldecode($sStr);
70
-    }
62
+private function decodeStr(string $sStr): string
63
+{
64
+$aServerParams = $this->di->getServerParams();
65
+$sContentType = $aServerParams['CONTENT_TYPE'] ?? $aServerParams['HTTP_CONTENT_TYPE'] ?? '';
66
+$sType = 'multipart/form-data';
67
+// Parameters are url encoded when uploading files
68
+return strncmp($sContentType, $sType, strlen($sType)) !== 0 ?
69
+$sStr : urldecode($sStr);
70
+}
71 71
 
72
-    /**
72
+/**
73 73
      * Decode input data.
74 74
      *
75 75
      * @param string $sStr
@@ -77,73 +77,73 @@  discard block
 block discarded – undo
77 77
      * @return string
78 78
      * @throws RequestException
79 79
      */
80
-    private function decoderUtf8Str(string $sStr): string
81
-    {
82
-        $sEncoding = $this->xConfigManager->getOption('core.encoding', '');
83
-        if(function_exists('iconv'))
84
-        {
85
-            return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr);
86
-        }
87
-        if(function_exists('mb_convert_encoding'))
88
-        {
89
-            return mb_convert_encoding($sStr, $sEncoding, "UTF-8");
90
-        }
91
-        // By default, no decoding
92
-        // return $sStr;
93
-        throw new RequestException($this->xTranslator->trans('errors.request.conversion'));
94
-    }
80
+private function decoderUtf8Str(string $sStr): string
81
+{
82
+$sEncoding = $this->xConfigManager->getOption('core.encoding', '');
83
+if(function_exists('iconv'))
84
+{
85
+return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr);
86
+}
87
+if(function_exists('mb_convert_encoding'))
88
+{
89
+return mb_convert_encoding($sStr, $sEncoding, "UTF-8");
90
+}
91
+// By default, no decoding
92
+// return $sStr;
93
+throw new RequestException($this->xTranslator->trans('errors.request.conversion'));
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * Choose the function to use to decode input data.
98 98
      *
99 99
      * @param string $sParam
100 100
      *
101 101
      * @return string
102 102
      */
103
-    private function decodeRequestParameter(string $sParam): string
104
-    {
105
-        $sParam = $this->decodeStr($sParam);
106
-        if(!$this->xConfigManager->getOption('core.decode_utf8'))
107
-        {
108
-            return $sParam;
109
-        }
110
-        $this->xConfigManager->setOption('core.decode_utf8', false);
111
-        return $this->decoderUtf8Str($sParam);
112
-    }
103
+private function decodeRequestParameter(string $sParam): string
104
+{
105
+$sParam = $this->decodeStr($sParam);
106
+if(!$this->xConfigManager->getOption('core.decode_utf8'))
107
+{
108
+return $sParam;
109
+}
110
+$this->xConfigManager->setOption('core.decode_utf8', false);
111
+return $this->decoderUtf8Str($sParam);
112
+}
113 113
 
114
-    /**
114
+/**
115 115
      * @param ServerRequestInterface $xRequest
116 116
      *
117 117
      * @return array|null
118 118
      */
119
-    public function getRequestParameter(ServerRequestInterface $xRequest): ?array
120
-    {
121
-        $aBody = $xRequest->getParsedBody();
122
-        $aParams = is_array($aBody) ? $aBody : $xRequest->getQueryParams();
123
-        // Check if Jaxon call parameters are present.
124
-        return !isset($aParams['jxncall']) || !is_string($aParams['jxncall']) ? null :
125
-            json_decode($this->decodeRequestParameter($aParams['jxncall']), true);
126
-    }
119
+public function getRequestParameter(ServerRequestInterface $xRequest): ?array
120
+{
121
+$aBody = $xRequest->getParsedBody();
122
+$aParams = is_array($aBody) ? $aBody : $xRequest->getQueryParams();
123
+// Check if Jaxon call parameters are present.
124
+return !isset($aParams['jxncall']) || !is_string($aParams['jxncall']) ? null :
125
+json_decode($this->decodeRequestParameter($aParams['jxncall']), true);
126
+}
127 127
 
128
-    /**
128
+/**
129 129
      * Get the URI of the current request
130 130
      *
131 131
      * @throws UriException
132 132
      */
133
-    public function uri(): string
134
-    {
135
-        return $this->xUriDetector->detect($this->di->getServerParams());
136
-    }
133
+public function uri(): string
134
+{
135
+return $this->xUriDetector->detect($this->di->getServerParams());
136
+}
137 137
 
138
-    /**
138
+/**
139 139
      * Make the specified URL suitable for redirect
140 140
      *
141 141
      * @param string $sURL    The relative or fully qualified URL
142 142
      *
143 143
      * @return string
144 144
      */
145
-    public function parseUrl(string $sURL): string
146
-    {
147
-        return $this->xUriDetector->redirect($sURL, $this->di->getServerParams());
148
-    }
145
+public function parseUrl(string $sURL): string
146
+{
147
+return $this->xUriDetector->redirect($sURL, $this->di->getServerParams());
148
+}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
     private function decoderUtf8Str(string $sStr): string
81 81
     {
82 82
         $sEncoding = $this->xConfigManager->getOption('core.encoding', '');
83
-        if(function_exists('iconv'))
83
+        if (function_exists('iconv'))
84 84
         {
85 85
             return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr);
86 86
         }
87
-        if(function_exists('mb_convert_encoding'))
87
+        if (function_exists('mb_convert_encoding'))
88 88
         {
89 89
             return mb_convert_encoding($sStr, $sEncoding, "UTF-8");
90 90
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     private function decodeRequestParameter(string $sParam): string
104 104
     {
105 105
         $sParam = $this->decodeStr($sParam);
106
-        if(!$this->xConfigManager->getOption('core.decode_utf8'))
106
+        if (!$this->xConfigManager->getOption('core.decode_utf8'))
107 107
         {
108 108
             return $sParam;
109 109
         }
Please login to merge, or discard this patch.