Passed
Push — main ( 238af9...5ca287 )
by Thierry
20:54 queued 15:16
created
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 1 patch
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.
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/ParameterReader.php 1 patch
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.
jaxon-core/src/Request/Upload/FileInterface.php 1 patch
Switch Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,52 +18,52 @@
 block discarded – undo
18 18
 
19 19
 interface FileInterface
20 20
 {
21
-    /**
21
+/**
22 22
      * Get the filesystem where the file is stored
23 23
      *
24 24
      * @return Filesystem
25 25
      */
26
-    public function filesystem(): Filesystem;
26
+public function filesystem(): Filesystem;
27 27
 
28
-    /**
28
+/**
29 29
      * Get the uploaded file type
30 30
      *
31 31
      * @return string
32 32
      */
33
-    public function type(): string;
33
+public function type(): string;
34 34
 
35
-    /**
35
+/**
36 36
      * Get the uploaded file name, without the extension and slugified
37 37
      *
38 38
      * @return string
39 39
      */
40
-    public function name(): string;
40
+public function name(): string;
41 41
 
42
-    /**
42
+/**
43 43
      * Get the uploaded file name, with the extension
44 44
      *
45 45
      * @return string
46 46
      */
47
-    public function filename(): string;
47
+public function filename(): string;
48 48
 
49
-    /**
49
+/**
50 50
      * Get the uploaded file path
51 51
      *
52 52
      * @return string
53 53
      */
54
-    public function path(): string;
54
+public function path(): string;
55 55
 
56
-    /**
56
+/**
57 57
      * Get the uploaded file size
58 58
      *
59 59
      * @return int
60 60
      */
61
-    public function size(): int;
61
+public function size(): int;
62 62
 
63
-    /**
63
+/**
64 64
      * Get the uploaded file extension
65 65
      *
66 66
      * @return string
67 67
      */
68
-    public function extension(): string;
68
+public function extension(): string;
69 69
 }
Please login to merge, or discard this patch.
jaxon-core/src/Script/Action/HtmlValue.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,49 +16,49 @@
 block discarded – undo
16 16
 
17 17
 class HtmlValue extends TypedValue
18 18
 {
19
-    /**
19
+/**
20 20
      * The class contructor
21 21
      *
22 22
      * @param array $aValue
23 23
      */
24
-    public function __construct(protected array $aValue)
25
-    {}
24
+public function __construct(protected array $aValue)
25
+{}
26 26
 
27
-    /**
27
+/**
28 28
      * @inheritDoc
29 29
      */
30
-    public function getType(): string
31
-    {
32
-        return $this->aValue['_type'] ?? '_';
33
-    }
30
+public function getType(): string
31
+{
32
+return $this->aValue['_type'] ?? '_';
33
+}
34 34
 
35
-    /**
35
+/**
36 36
      * Convert the js value to int
37 37
      *
38 38
      * @return self
39 39
      */
40
-    public function toInt(): self
41
-    {
42
-        $this->aValue['toInt'] = true;
43
-        return $this;
44
-    }
40
+public function toInt(): self
41
+{
42
+$this->aValue['toInt'] = true;
43
+return $this;
44
+}
45 45
 
46
-    /**
46
+/**
47 47
      * Trim the js value
48 48
      *
49 49
      * @return self
50 50
      */
51
-    public function trim(): self
52
-    {
53
-        $this->aValue['trim'] = true;
54
-        return $this;
55
-    }
51
+public function trim(): self
52
+{
53
+$this->aValue['trim'] = true;
54
+return $this;
55
+}
56 56
 
57
-    /**
57
+/**
58 58
      * @return array
59 59
      */
60
-    public function jsonSerialize(): array
61
-    {
62
-        return $this->aValue;
63
-    }
60
+public function jsonSerialize(): array
61
+{
62
+return $this->aValue;
63
+}
64 64
 }
Please login to merge, or discard this patch.
jaxon-core/src/Script/Action/Event.php 1 patch
Switch Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,29 +7,29 @@
 block discarded – undo
7 7
 
8 8
 class Event implements JsonSerializable
9 9
 {
10
-    /**
10
+/**
11 11
      * The constructor.
12 12
      *
13 13
      * @param string $sMode    The event mode: 'jq' or 'js'
14 14
      * @param string $sName    The event name
15 15
      * @param JsExpr $xHandler   The event handler
16 16
      */
17
-    public function __construct(private string $sMode,
18
-        private string $sName, private JsExpr $xHandler)
19
-    {}
17
+public function __construct(private string $sMode,
18
+private string $sName, private JsExpr $xHandler)
19
+{}
20 20
 
21
-    /**
21
+/**
22 22
      * Convert this call to array, when converting the response into json.
23 23
      *
24 24
      * @return array
25 25
      */
26
-    public function jsonSerialize(): array
27
-    {
28
-        return [
29
-            '_type' => 'event',
30
-            '_name' => $this->sName,
31
-            'mode' => $this->sMode,
32
-            'func' => $this->xHandler->jsonSerialize(),
33
-        ];
34
-    }
26
+public function jsonSerialize(): array
27
+{
28
+return [
29
+'_type' => 'event',
30
+'_name' => $this->sName,
31
+'mode' => $this->sMode,
32
+'func' => $this->xHandler->jsonSerialize(),
33
+];
34
+}
35 35
 }
Please login to merge, or discard this patch.
jaxon-core/src/Script/Action/SimpleValue.php 1 patch
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,25 +15,25 @@
 block discarded – undo
15 15
 
16 16
 class SimpleValue extends TypedValue
17 17
 {
18
-    /**
18
+/**
19 19
      * @param mixed $xValue
20 20
      */
21
-    public function __construct(private mixed $xValue)
22
-    {}
21
+public function __construct(private mixed $xValue)
22
+{}
23 23
 
24
-    /**
24
+/**
25 25
      * @inheritDoc
26 26
      */
27
-    public function getType(): string
28
-    {
29
-        return '_';
30
-    }
27
+public function getType(): string
28
+{
29
+return '_';
30
+}
31 31
 
32
-    /**
32
+/**
33 33
      * @return mixed
34 34
      */
35
-    public function jsonSerialize(): mixed
36
-    {
37
-        return $this->xValue;
38
-    }
35
+public function jsonSerialize(): mixed
36
+{
37
+return $this->xValue;
38
+}
39 39
 }
Please login to merge, or discard this patch.
jaxon-core/src/Script/Action/PageValue.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@
 block discarded – undo
15 15
 
16 16
 class PageValue extends TypedValue
17 17
 {
18
-    /**
18
+/**
19 19
      * @return string
20 20
      */
21
-    public function getType(): string
22
-    {
23
-        return 'page';
24
-    }
21
+public function getType(): string
22
+{
23
+return 'page';
24
+}
25 25
 
26
-    /**
26
+/**
27 27
      * @return array
28 28
      */
29
-    public function jsonSerialize(): array
30
-    {
31
-        return ['_type' => 'page', '_name' => ''];
32
-    }
29
+public function jsonSerialize(): array
30
+{
31
+return ['_type' => 'page', '_name' => ''];
32
+}
33 33
 }
Please login to merge, or discard this patch.