Passed
Push — main ( 273db0...683317 )
by Thierry
03:54
created
jaxon-core/src/Plugin/Code/MinifierInterface.php 1 patch
Switch Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 interface MinifierInterface
6 6
 {
7
-    /**
7
+/**
8 8
      * Minify javascript code
9 9
      *
10 10
      * @param string $sJsFile The javascript file to be minified
@@ -12,5 +12,5 @@  discard block
 block discarded – undo
12 12
      *
13 13
      * @return bool
14 14
      */
15
-    public function minify(string $sJsFile, string $sMinFile): bool;
15
+public function minify(string $sJsFile, string $sMinFile): bool;
16 16
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Pagination/PaginatorPlugin.php 1 patch
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -43,60 +43,60 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class PaginatorPlugin extends AbstractResponsePlugin
45 45
 {
46
-    /**
46
+/**
47 47
      * @const The plugin name
48 48
      */
49
-    public const NAME = 'pg';
49
+public const NAME = 'pg';
50 50
 
51
-    /**
51
+/**
52 52
      * The constructor.
53 53
      *
54 54
      * @param RendererInterface $xRenderer
55 55
      */
56
-    public function __construct(protected RendererInterface $xRenderer)
57
-    {}
56
+public function __construct(protected RendererInterface $xRenderer)
57
+{}
58 58
 
59
-    /**
59
+/**
60 60
      * @inheritDoc
61 61
      */
62
-    public function getName(): string
63
-    {
64
-        return self::NAME;
65
-    }
62
+public function getName(): string
63
+{
64
+return self::NAME;
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * @inheritDoc
69 69
      */
70
-    public function getHash(): string
71
-    {
72
-        return '5.0.0'; // Use the version number as hash
73
-    }
70
+public function getHash(): string
71
+{
72
+return '5.0.0'; // Use the version number as hash
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @inheritDoc
77 77
      */
78
-    public function getCss(): string
79
-    {
80
-        return '
78
+public function getCss(): string
79
+{
80
+return '
81 81
 <style>
82 82
   .pagination li a {
83 83
     cursor: pointer;
84 84
   }
85 85
 </style>
86 86
 ';
87
-    }
87
+}
88 88
 
89
-    /**
89
+/**
90 90
      * Get the view renderer
91 91
      *
92 92
      * @return RendererInterface
93 93
      */
94
-    public function renderer(): RendererInterface
95
-    {
96
-        return $this->xRenderer;
97
-    }
94
+public function renderer(): RendererInterface
95
+{
96
+return $this->xRenderer;
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * Create a paginator
101 101
      *
102 102
      * @param int $nPageNumber     The current page number
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return Paginator
107 107
      */
108
-    public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator
109
-    {
110
-        return new Paginator($this, $nPageNumber, $nItemsPerPage, $nTotalItems);
111
-    }
108
+public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator
109
+{
110
+return new Paginator($this, $nPageNumber, $nItemsPerPage, $nTotalItems);
111
+}
112 112
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Script/ScriptPlugin.php 1 patch
Switch Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -26,56 +26,56 @@  discard block
 block discarded – undo
26 26
 
27 27
 class ScriptPlugin extends AbstractResponsePlugin
28 28
 {
29
-    /**
29
+/**
30 30
      * @const The plugin name
31 31
      */
32
-    public const NAME = 'script';
32
+public const NAME = 'script';
33 33
 
34
-    /**
34
+/**
35 35
      * The class constructor
36 36
      *
37 37
      * @param CallFactory $xFactory
38 38
      */
39
-    public function __construct(private CallFactory $xFactory)
40
-    {}
39
+public function __construct(private CallFactory $xFactory)
40
+{}
41 41
 
42
-    /**
42
+/**
43 43
      * @return Closure
44 44
      */
45
-    private function getCallback(): Closure
46
-    {
47
-        // The closure needs to capture the response object the script plugin is called with.
48
-        $xResponse = $this->response();
49
-        return function(JsExpr $xJsExpr) use($xResponse) {
50
-            // Add the newly created expression to the response
51
-            $aOptions = [
52
-                'expr' => $xJsExpr,
53
-                'context' => is_a($xResponse, NodeResponse::class) ?
54
-                    ['component' => true] : [],
55
-            ];
56
-            $xResponse->addCommand('script.exec.expr', $aOptions)
57
-                ->setOption('plugin', $this->getName());
58
-        };
59
-    }
45
+private function getCallback(): Closure
46
+{
47
+// The closure needs to capture the response object the script plugin is called with.
48
+$xResponse = $this->response();
49
+return function(JsExpr $xJsExpr) use($xResponse) {
50
+// Add the newly created expression to the response
51
+$aOptions = [
52
+    'expr' => $xJsExpr,
53
+    'context' => is_a($xResponse, NodeResponse::class) ?
54
+        ['component' => true] : [],
55
+];
56
+$xResponse->addCommand('script.exec.expr', $aOptions)
57
+    ->setOption('plugin', $this->getName());
58
+};
59
+}
60 60
 
61
-    /**
61
+/**
62 62
      * @inheritDoc
63 63
      */
64
-    public function getName(): string
65
-    {
66
-        return self::NAME;
67
-    }
64
+public function getName(): string
65
+{
66
+return self::NAME;
67
+}
68 68
 
69
-    /**
69
+/**
70 70
      * @inheritDoc
71 71
      */
72
-    public function getHash(): string
73
-    {
74
-        // Use the version number as hash
75
-        return '5.0.0';
76
-    }
72
+public function getHash(): string
73
+{
74
+// Use the version number as hash
75
+return '5.0.0';
76
+}
77 77
 
78
-    /**
78
+/**
79 79
      * Create a JQuery selector expression, and link it to the current response.
80 80
      *
81 81
      * @param string $sPath    The jQuery selector path
@@ -83,32 +83,32 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * @return JqSelectorCall
85 85
      */
86
-    public function jq(string $sPath = '', $xContext = null): JqSelectorCall
87
-    {
88
-        return $this->xFactory->jq($sPath, $xContext, $this->getCallback());
89
-    }
86
+public function jq(string $sPath = '', $xContext = null): JqSelectorCall
87
+{
88
+return $this->xFactory->jq($sPath, $xContext, $this->getCallback());
89
+}
90 90
 
91
-    /**
91
+/**
92 92
      * Create a Javascript object expression, and link it to the current response.
93 93
      *
94 94
      * @param string $sObject
95 95
      *
96 96
      * @return JsObjectCall
97 97
      */
98
-    public function jo(string $sObject = ''): JsObjectCall
99
-    {
100
-        return $this->xFactory->jo($sObject, $this->getCallback());
101
-    }
98
+public function jo(string $sObject = ''): JsObjectCall
99
+{
100
+return $this->xFactory->jo($sObject, $this->getCallback());
101
+}
102 102
 
103
-    /**
103
+/**
104 104
      * Create a Javascript element selector expression, and link it to the current response.
105 105
      *
106 106
      * @param string $sElementId
107 107
      *
108 108
      * @return JsSelectorCall
109 109
      */
110
-    public function je(string $sElementId = ''): JsSelectorCall
111
-    {
112
-        return $this->xFactory->je($sElementId, $this->getCallback());
113
-    }
110
+public function je(string $sElementId = ''): JsSelectorCall
111
+{
112
+return $this->xFactory->je($sElementId, $this->getCallback());
113
+}
114 114
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Dialog/DialogPlugin.php 1 patch
Switch Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -24,107 +24,107 @@
 block discarded – undo
24 24
 
25 25
 class DialogPlugin implements PluginInterface, ResponsePluginInterface, ModalInterface, AlertInterface
26 26
 {
27
-    use ResponsePluginTrait;
27
+use ResponsePluginTrait;
28 28
 
29
-    /**
29
+/**
30 30
      * @const The plugin name
31 31
      */
32
-    public const NAME = 'dialog';
32
+public const NAME = 'dialog';
33 33
 
34
-    /**
34
+/**
35 35
      * The constructor
36 36
      *
37 37
      * @param DialogCommand $xDialogCommand
38 38
      */
39
-    public function __construct(private DialogCommand $xDialogCommand)
40
-    {}
39
+public function __construct(private DialogCommand $xDialogCommand)
40
+{}
41 41
 
42
-    /**
42
+/**
43 43
      * @inheritDoc
44 44
      */
45
-    public function getName(): string
46
-    {
47
-        return self::NAME;
48
-    }
45
+public function getName(): string
46
+{
47
+return self::NAME;
48
+}
49 49
 
50
-    /**
50
+/**
51 51
      * Initialize the plugin
52 52
      *
53 53
      * @return void
54 54
      */
55
-    protected function init(): void
56
-    {}
55
+protected function init(): void
56
+{}
57 57
 
58
-    /**
58
+/**
59 59
      * Set the library to use for the next call.
60 60
      *
61 61
      * @param string $sLibrary The name of the library
62 62
      *
63 63
      * @return DialogPlugin
64 64
      */
65
-    public function with(string $sLibrary): DialogPlugin
66
-    {
67
-        $this->xDialogCommand->library($sLibrary);
68
-        return $this;
69
-    }
65
+public function with(string $sLibrary): DialogPlugin
66
+{
67
+$this->xDialogCommand->library($sLibrary);
68
+return $this;
69
+}
70 70
 
71
-    /**
71
+/**
72 72
      * @inheritDoc
73 73
      */
74
-    public function show(string $sTitle, string $sContent, array $aButtons = [], array $aOptions = []): void
75
-    {
76
-        // Show the modal dialog
77
-        $this->addCommand('dialog.modal.show',
78
-            $this->xDialogCommand->show($sTitle, $sContent, $aButtons, $aOptions));
79
-    }
80
-
81
-    /**
74
+public function show(string $sTitle, string $sContent, array $aButtons = [], array $aOptions = []): void
75
+{
76
+// Show the modal dialog
77
+$this->addCommand('dialog.modal.show',
78
+$this->xDialogCommand->show($sTitle, $sContent, $aButtons, $aOptions));
79
+}
80
+
81
+/**
82 82
      * @inheritDoc
83 83
      */
84
-    public function hide(): void
85
-    {
86
-        // Hide the modal dialog
87
-        $this->addCommand('dialog.modal.hide', $this->xDialogCommand->hide());
88
-    }
84
+public function hide(): void
85
+{
86
+// Hide the modal dialog
87
+$this->addCommand('dialog.modal.hide', $this->xDialogCommand->hide());
88
+}
89 89
 
90
-    /**
90
+/**
91 91
      * @inheritDoc
92 92
      */
93
-    public function title(string $sTitle): AlertInterface
94
-    {
95
-        $this->xDialogCommand->title($sTitle);
96
-        return $this;
97
-    }
93
+public function title(string $sTitle): AlertInterface
94
+{
95
+$this->xDialogCommand->title($sTitle);
96
+return $this;
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * @inheritDoc
101 101
      */
102
-    public function success(string $sMessage, ...$aArgs): void
103
-    {
104
-        $this->addCommand('dialog.alert.show', $this->xDialogCommand->success($sMessage, $aArgs));
105
-    }
102
+public function success(string $sMessage, ...$aArgs): void
103
+{
104
+$this->addCommand('dialog.alert.show', $this->xDialogCommand->success($sMessage, $aArgs));
105
+}
106 106
 
107
-    /**
107
+/**
108 108
      * @inheritDoc
109 109
      */
110
-    public function info(string $sMessage, ...$aArgs): void
111
-    {
112
-        $this->addCommand('dialog.alert.show', $this->xDialogCommand->info($sMessage, $aArgs));
113
-    }
110
+public function info(string $sMessage, ...$aArgs): void
111
+{
112
+$this->addCommand('dialog.alert.show', $this->xDialogCommand->info($sMessage, $aArgs));
113
+}
114 114
 
115
-    /**
115
+/**
116 116
      * @inheritDoc
117 117
      */
118
-    public function warning(string $sMessage, ...$aArgs): void
119
-    {
120
-        $this->addCommand('dialog.alert.show', $this->xDialogCommand->warning($sMessage, $aArgs));
121
-    }
118
+public function warning(string $sMessage, ...$aArgs): void
119
+{
120
+$this->addCommand('dialog.alert.show', $this->xDialogCommand->warning($sMessage, $aArgs));
121
+}
122 122
 
123
-    /**
123
+/**
124 124
      * @inheritDoc
125 125
      */
126
-    public function error(string $sMessage, ...$aArgs): void
127
-    {
128
-        $this->addCommand('dialog.alert.show', $this->xDialogCommand->error($sMessage, $aArgs));
129
-    }
126
+public function error(string $sMessage, ...$aArgs): void
127
+{
128
+$this->addCommand('dialog.alert.show', $this->xDialogCommand->error($sMessage, $aArgs));
129
+}
130 130
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/AbstractCodeGenerator.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,43 +18,43 @@
 block discarded – undo
18 18
 
19 19
 abstract class AbstractCodeGenerator implements CodeGeneratorInterface
20 20
 {
21
-    /**
21
+/**
22 22
      * @inheritDoc
23 23
      */
24
-    public function getHash(): string
25
-    {
26
-        return '';
27
-    }
24
+public function getHash(): string
25
+{
26
+return '';
27
+}
28 28
 
29
-    /**
29
+/**
30 30
      * @inheritDoc
31 31
      */
32
-    public function getCss(): string
33
-    {
34
-        return '';
35
-    }
32
+public function getCss(): string
33
+{
34
+return '';
35
+}
36 36
 
37
-    /**
37
+/**
38 38
      * @inheritDoc
39 39
      */
40
-    public function getJs(): string
41
-    {
42
-        return '';
43
-    }
40
+public function getJs(): string
41
+{
42
+return '';
43
+}
44 44
 
45
-    /**
45
+/**
46 46
      * @inheritDoc
47 47
      */
48
-    public function getScript(): string
49
-    {
50
-        return '';
51
-    }
48
+public function getScript(): string
49
+{
50
+return '';
51
+}
52 52
 
53
-    /**
53
+/**
54 54
      * @inheritDoc
55 55
      */
56
-    public function getJsCode(): ?JsCode
57
-    {
58
-        return null;
59
-    }
56
+public function getJsCode(): ?JsCode
57
+{
58
+return null;
59
+}
60 60
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/ResponsePluginTrait.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,48 +31,48 @@  discard block
 block discarded – undo
31 31
 
32 32
 trait ResponsePluginTrait
33 33
 {
34
-    /**
34
+/**
35 35
      * The object used to build the response that will be sent to the client browser
36 36
      *
37 37
      * @var AbstractResponse
38 38
      */
39
-    private $xResponse = null;
39
+private $xResponse = null;
40 40
 
41
-    /**
41
+/**
42 42
      * Get a unique name to identify the plugin.
43 43
      *
44 44
      * @return string
45 45
      */
46
-    abstract public function getName(): string;
46
+abstract public function getName(): string;
47 47
 
48
-    /**
48
+/**
49 49
      * Initialize the plugin
50 50
      *
51 51
      * @return void
52 52
      */
53
-    abstract protected function init();
53
+abstract protected function init();
54 54
 
55
-    /**
55
+/**
56 56
      * @param AbstractResponse $xResponse   The response
57 57
      *
58 58
      * @return static
59 59
      */
60
-    public function initPlugin(AbstractResponse $xResponse): static
61
-    {
62
-        $this->xResponse = $xResponse;
63
-        $this->init();
64
-        return $this;
65
-    }
60
+public function initPlugin(AbstractResponse $xResponse): static
61
+{
62
+$this->xResponse = $xResponse;
63
+$this->init();
64
+return $this;
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * @inheritDoc
69 69
      */
70
-    public function response(): ?AbstractResponse
71
-    {
72
-        return $this->xResponse;
73
-    }
70
+public function response(): ?AbstractResponse
71
+{
72
+return $this->xResponse;
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * Add a plugin command to the response
77 77
      *
78 78
      * @param string $sName    The command name
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return Command
82 82
      */
83
-    public function addCommand(string $sName, array|JsonSerializable $aOptions): Command
84
-    {
85
-        return $this->xResponse
86
-            ->addCommand($sName, $aOptions)
87
-            ->setOption('plugin', $this->getName());
88
-    }
83
+public function addCommand(string $sName, array|JsonSerializable $aOptions): Command
84
+{
85
+return $this->xResponse
86
+->addCommand($sName, $aOptions)
87
+->setOption('plugin', $this->getName());
88
+}
89 89
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/CodeGeneratorInterface.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,46 +17,46 @@
 block discarded – undo
17 17
 
18 18
 interface CodeGeneratorInterface
19 19
 {
20
-    /**
20
+/**
21 21
      * Get the value to be hashed
22 22
      *
23 23
      * @return string
24 24
      */
25
-    public function getHash(): string;
25
+public function getHash(): string;
26 26
 
27
-    /**
27
+/**
28 28
      * Get the HTML tags to include CSS code and files into the page
29 29
      *
30 30
      * The code must be enclosed in the appropriate HTML tags.
31 31
      *
32 32
      * @return string
33 33
      */
34
-    public function getCss(): string;
34
+public function getCss(): string;
35 35
 
36
-    /**
36
+/**
37 37
      * Get the HTML tags to include javascript code and files into the page
38 38
      *
39 39
      * The code must be enclosed in the appropriate HTML tags.
40 40
      *
41 41
      * @return string
42 42
      */
43
-    public function getJs(): string;
43
+public function getJs(): string;
44 44
 
45
-    /**
45
+/**
46 46
      * Get the javascript code to include into the page
47 47
      *
48 48
      * The code must NOT be enclosed in HTML tags.
49 49
      *
50 50
      * @return string
51 51
      */
52
-    public function getScript(): string;
52
+public function getScript(): string;
53 53
 
54
-    /**
54
+/**
55 55
      * Get the javascript codes to include into the page
56 56
      *
57 57
      * The code must NOT be enclosed in HTML tags.
58 58
      *
59 59
      * @return JsCode|null
60 60
      */
61
-    public function getJsCode(): ?JsCode;
61
+public function getJsCode(): ?JsCode;
62 62
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
         if(is_string($xOptions))
86 86
         {
87 87
             $xOptions = ['include' => $xOptions];
88
-        }
89
-        elseif(!is_array($xOptions))
88
+        } elseif(!is_array($xOptions))
90 89
         {
91 90
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
92 91
         }
@@ -261,8 +260,7 @@  discard block
 block discarded – undo
261 260
 
262 261
             $sError = 'errors.objects.call';
263 262
             $xCallableObject->call($this->xTarget);
264
-        }
265
-        catch(ReflectionException|SetupException $e)
263
+        } catch(ReflectionException|SetupException $e)
266 264
         {
267 265
             // Unable to execute the requested class or method
268 266
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
Switch Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
 
47 47
 class CallableClassPlugin extends AbstractRequestPlugin
48 48
 {
49
-    /**
49
+/**
50 50
      * @var array<CallableObject>
51 51
      */
52
-    private array $aCallableObjects = [];
52
+private array $aCallableObjects = [];
53 53
 
54
-    /**
54
+/**
55 55
      * @var array<string>
56 56
      */
57
-    private array $aCallableNames = [];
57
+private array $aCallableNames = [];
58 58
 
59
-    /**
59
+/**
60 60
      * The class constructor
61 61
      *
62 62
      * @param string $sPrefix
@@ -67,150 +67,150 @@  discard block
 block discarded – undo
67 67
      * @param TemplateEngine $xTemplateEngine
68 68
      * @param Validator $xValidator
69 69
      */
70
-    public function __construct(private string $sPrefix,
71
-        private LoggerInterface $xLogger, private ComponentContainer $cdi,
72
-        private ComponentRegistry $xRegistry, private Translator $xTranslator,
73
-        private TemplateEngine $xTemplateEngine, private Validator $xValidator)
74
-    {}
70
+public function __construct(private string $sPrefix,
71
+private LoggerInterface $xLogger, private ComponentContainer $cdi,
72
+private ComponentRegistry $xRegistry, private Translator $xTranslator,
73
+private TemplateEngine $xTemplateEngine, private Validator $xValidator)
74
+{}
75 75
 
76
-    /**
76
+/**
77 77
      * @inheritDoc
78 78
      */
79
-    public function getName(): string
80
-    {
81
-        return Jaxon::CALLABLE_CLASS;
82
-    }
79
+public function getName(): string
80
+{
81
+return Jaxon::CALLABLE_CLASS;
82
+}
83 83
 
84
-    /**
84
+/**
85 85
      * @inheritDoc
86 86
      * @throws SetupException
87 87
      */
88
-    public function checkOptions(string $sCallable, $xOptions): array
89
-    {
90
-        if(!$this->xValidator->validateClass(trim($sCallable)))
91
-        {
92
-            throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
93
-        }
94
-        if(is_string($xOptions))
95
-        {
96
-            $xOptions = ['include' => $xOptions];
97
-        }
98
-        elseif(!is_array($xOptions))
99
-        {
100
-            throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
101
-        }
102
-        return $xOptions;
103
-    }
104
-
105
-    /**
88
+public function checkOptions(string $sCallable, $xOptions): array
89
+{
90
+if(!$this->xValidator->validateClass(trim($sCallable)))
91
+{
92
+throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
93
+}
94
+if(is_string($xOptions))
95
+{
96
+$xOptions = ['include' => $xOptions];
97
+}
98
+elseif(!is_array($xOptions))
99
+{
100
+throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
101
+}
102
+return $xOptions;
103
+}
104
+
105
+/**
106 106
      * @inheritDoc
107 107
      */
108
-    public function register(string $sType, string $sCallable, array $aOptions): bool
109
-    {
110
-        $sClassName = trim($sCallable);
111
-        $this->xRegistry->registerComponent($sClassName, $aOptions);
112
-        return true;
113
-    }
114
-
115
-    /**
108
+public function register(string $sType, string $sCallable, array $aOptions): bool
109
+{
110
+$sClassName = trim($sCallable);
111
+$this->xRegistry->registerComponent($sClassName, $aOptions);
112
+return true;
113
+}
114
+
115
+/**
116 116
      * @inheritDoc
117 117
      * @throws SetupException
118 118
      */
119
-    public function getCallable(string $sCallable): CallableObject|null
120
-    {
121
-        return $this->cdi->makeCallableObject($sCallable);
122
-    }
119
+public function getCallable(string $sCallable): CallableObject|null
120
+{
121
+return $this->cdi->makeCallableObject($sCallable);
122
+}
123 123
 
124
-    /**
124
+/**
125 125
      * @inheritDoc
126 126
      */
127
-    public function getHash(): string
128
-    {
129
-        $this->xRegistry->registerAllComponents();
130
-        return md5($this->xRegistry->getHash());
131
-    }
127
+public function getHash(): string
128
+{
129
+$this->xRegistry->registerAllComponents();
130
+return md5($this->xRegistry->getHash());
131
+}
132 132
 
133
-    /**
133
+/**
134 134
      * Add a callable object to the script generator
135 135
      *
136 136
      * @param CallableObject $xCallableObject
137 137
      *
138 138
      * @return void
139 139
      */
140
-    private function addCallable(CallableObject $xCallableObject): void
141
-    {
142
-        $aCallableMethods = $xCallableObject->getCallableMethods();
143
-        if($xCallableObject->excluded() || count($aCallableMethods) === 0)
144
-        {
145
-            return;
146
-        }
147
-
148
-        $aCallableObject = &$this->aCallableObjects;
149
-        $sJsName = $xCallableObject->getJsName();
150
-        foreach(explode('.', $sJsName) as $sName)
151
-        {
152
-            if(!isset($aCallableObject['children'][$sName]))
153
-            {
154
-                $aCallableObject['children'][$sName] = [];
155
-            }
156
-            $aCallableObject = &$aCallableObject['children'][$sName];
157
-        }
158
-
159
-        $aCallableObject['methods'] = $aCallableMethods;
160
-        $aCallableObject['index'] = count($this->aCallableNames);
161
-        $this->aCallableNames[] = $sJsName;
162
-    }
163
-
164
-    /**
140
+private function addCallable(CallableObject $xCallableObject): void
141
+{
142
+$aCallableMethods = $xCallableObject->getCallableMethods();
143
+if($xCallableObject->excluded() || count($aCallableMethods) === 0)
144
+{
145
+return;
146
+}
147
+
148
+$aCallableObject = &$this->aCallableObjects;
149
+$sJsName = $xCallableObject->getJsName();
150
+foreach(explode('.', $sJsName) as $sName)
151
+{
152
+if(!isset($aCallableObject['children'][$sName]))
153
+{
154
+    $aCallableObject['children'][$sName] = [];
155
+}
156
+$aCallableObject = &$aCallableObject['children'][$sName];
157
+}
158
+
159
+$aCallableObject['methods'] = $aCallableMethods;
160
+$aCallableObject['index'] = count($this->aCallableNames);
161
+$this->aCallableNames[] = $sJsName;
162
+}
163
+
164
+/**
165 165
      * @param string $sIndent
166 166
      * @param array $aTemplateVars
167 167
      *
168 168
      * @return string
169 169
      */
170
-    private function renderMethod(string $sIndent, array $aTemplateVars): string
171
-    {
172
-        $aOptions = [];
173
-        foreach($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
174
-        {
175
-            $aOptions[] = "$sKey: $sValue";
176
-        }
177
-        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' :
178
-            'args, { ' . implode(', ', $aOptions) . ' }';
179
-
180
-        return $sIndent . trim($this->xTemplateEngine
181
-            ->render('jaxon::callables/method.js', $aTemplateVars));
182
-    }
183
-
184
-    /**
170
+private function renderMethod(string $sIndent, array $aTemplateVars): string
171
+{
172
+$aOptions = [];
173
+foreach($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
174
+{
175
+$aOptions[] = "$sKey: $sValue";
176
+}
177
+$aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' :
178
+'args, { ' . implode(', ', $aOptions) . ' }';
179
+
180
+return $sIndent . trim($this->xTemplateEngine
181
+->render('jaxon::callables/method.js', $aTemplateVars));
182
+}
183
+
184
+/**
185 185
      * @param string $sJsClass
186 186
      * @param array $aCallable
187 187
      * @param int $nIndent
188 188
      *
189 189
      * @return string
190 190
      */
191
-    private function renderCallable(string $sJsClass, array $aCallable, int $nIndent): string
192
-    {
193
-        $nIndent += 2; // Indentation.
194
-        $sIndent = str_repeat(' ', $nIndent);
195
-
196
-        $fMethodCallback = fn($aMethod) => $this->renderMethod($sIndent, [
197
-            'aMethod' => $aMethod,
198
-            'nIndex' => $aCallable['index'] ?? 0,
199
-        ]);
200
-        $aMethods = !isset($aCallable['methods']) ? [] :
201
-            array_map($fMethodCallback, $aCallable['methods']);
202
-
203
-        $aChildren = [];
204
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
205
-        {
206
-            $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
207
-                $aChild, $nIndent) . ',';
208
-        }
209
-
210
-        return implode("\n", array_merge($aMethods, $aChildren));
211
-    }
212
-
213
-    /**
191
+private function renderCallable(string $sJsClass, array $aCallable, int $nIndent): string
192
+{
193
+$nIndent += 2; // Indentation.
194
+$sIndent = str_repeat(' ', $nIndent);
195
+
196
+$fMethodCallback = fn($aMethod) => $this->renderMethod($sIndent, [
197
+'aMethod' => $aMethod,
198
+'nIndex' => $aCallable['index'] ?? 0,
199
+]);
200
+$aMethods = !isset($aCallable['methods']) ? [] :
201
+array_map($fMethodCallback, $aCallable['methods']);
202
+
203
+$aChildren = [];
204
+foreach($aCallable['children'] ?? [] as $sName => $aChild)
205
+{
206
+$aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
207
+    $aChild, $nIndent) . ',';
208
+}
209
+
210
+return implode("\n", array_merge($aMethods, $aChildren));
211
+}
212
+
213
+/**
214 214
      * @param string $sJsVar
215 215
      * @param string $sJsClass
216 216
      * @param array $aCallable
@@ -218,70 +218,70 @@  discard block
 block discarded – undo
218 218
      *
219 219
      * @return string
220 220
      */
221
-    private function renderChild(string $sJsVar, string $sJsClass,
222
-        array $aCallable, int $nIndent = 0): string
223
-    {
224
-        $sIndent = str_repeat(' ', $nIndent);
225
-        $sScript = $this->renderCallable($sJsClass, $aCallable, $nIndent);
221
+private function renderChild(string $sJsVar, string $sJsClass,
222
+array $aCallable, int $nIndent = 0): string
223
+{
224
+$sIndent = str_repeat(' ', $nIndent);
225
+$sScript = $this->renderCallable($sJsClass, $aCallable, $nIndent);
226 226
 
227
-        return <<<CODE
227
+return <<<CODE
228 228
 $sIndent$sJsVar {
229 229
 $sScript
230 230
 $sIndent}
231 231
 CODE;
232
-    }
232
+}
233 233
 
234
-    /**
234
+/**
235 235
      * Generate client side javascript code for the registered callable objects
236 236
      *
237 237
      * @return string
238 238
      * @throws SetupException
239 239
      */
240
-    public function getScript(): string
241
-    {
242
-        $this->xRegistry->registerAllComponents();
243
-
244
-        $this->aCallableNames = [];
245
-        $this->aCallableObjects = ['children' => []];
246
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
247
-        {
248
-            $this->addCallable($xCallableObject);
249
-        }
250
-
251
-        $aScripts = [
252
-            $this->xTemplateEngine ->render('jaxon::callables/objects.js', [
253
-                'aCallableNames' => $this->aCallableNames,
254
-            ])
255
-        ];
256
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
257
-        {
258
-            $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
259
-                $sJsClass, $aCallable) . ';';
260
-        }
261
-        return implode("\n", $aScripts) . "\n";
262
-    }
263
-
264
-    /**
240
+public function getScript(): string
241
+{
242
+$this->xRegistry->registerAllComponents();
243
+
244
+$this->aCallableNames = [];
245
+$this->aCallableObjects = ['children' => []];
246
+foreach($this->cdi->getCallableObjects() as $xCallableObject)
247
+{
248
+$this->addCallable($xCallableObject);
249
+}
250
+
251
+$aScripts = [
252
+$this->xTemplateEngine ->render('jaxon::callables/objects.js', [
253
+    'aCallableNames' => $this->aCallableNames,
254
+])
255
+];
256
+foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
257
+{
258
+$aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
259
+    $sJsClass, $aCallable) . ';';
260
+}
261
+return implode("\n", $aScripts) . "\n";
262
+}
263
+
264
+/**
265 265
      * @inheritDoc
266 266
      */
267
-    public static function canProcessRequest(ServerRequestInterface $xRequest): bool
268
-    {
269
-        $aCall = $xRequest->getAttribute('jxncall');
270
-        return $aCall !== null && ($aCall['type'] ?? '') === 'class' &&
271
-            isset($aCall['name']) && isset($aCall['method']) &&
272
-            is_string($aCall['name']) && is_string($aCall['method']);
273
-    }
274
-
275
-    /**
267
+public static function canProcessRequest(ServerRequestInterface $xRequest): bool
268
+{
269
+$aCall = $xRequest->getAttribute('jxncall');
270
+return $aCall !== null && ($aCall['type'] ?? '') === 'class' &&
271
+isset($aCall['name']) && isset($aCall['method']) &&
272
+is_string($aCall['name']) && is_string($aCall['method']);
273
+}
274
+
275
+/**
276 276
      * @inheritDoc
277 277
      */
278
-    public function setTarget(ServerRequestInterface $xRequest): Target
279
-    {
280
-        $this->xTarget = Target::makeClass($xRequest->getAttribute('jxncall'));
281
-        return $this->xTarget;
282
-    }
278
+public function setTarget(ServerRequestInterface $xRequest): Target
279
+{
280
+$this->xTarget = Target::makeClass($xRequest->getAttribute('jxncall'));
281
+return $this->xTarget;
282
+}
283 283
 
284
-    /**
284
+/**
285 285
      * @param string $sExceptionMessage
286 286
      * @param string $sErrorCode
287 287
      * @param array $aErrorParams
@@ -289,53 +289,53 @@  discard block
 block discarded – undo
289 289
      * @throws RequestException
290 290
      * @return void
291 291
      */
292
-    private function throwException(string $sExceptionMessage,
293
-        string $sErrorCode, array $aErrorParams = []): void
294
-    {
295
-        $sMessage = $this->xTranslator->trans($sErrorCode, $aErrorParams) .
296
-            (!$sExceptionMessage ? '' : "\n$sExceptionMessage");
297
-        $this->xLogger->error($sMessage);
298
-        throw new RequestException($sMessage);
299
-    }
300
-
301
-    /**
292
+private function throwException(string $sExceptionMessage,
293
+string $sErrorCode, array $aErrorParams = []): void
294
+{
295
+$sMessage = $this->xTranslator->trans($sErrorCode, $aErrorParams) .
296
+(!$sExceptionMessage ? '' : "\n$sExceptionMessage");
297
+$this->xLogger->error($sMessage);
298
+throw new RequestException($sMessage);
299
+}
300
+
301
+/**
302 302
      * @inheritDoc
303 303
      * @throws RequestException
304 304
      */
305
-    public function processRequest(): void
306
-    {
307
-        $sClassName = $this->xTarget->getClassName();
308
-        $sMethodName = $this->xTarget->getMethodName();
309
-        // Will be used to print a translated error message.
310
-        $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
311
-
312
-        if(!$this->xValidator->validateJsObject($sClassName) ||
313
-            !$this->xValidator->validateMethod($sMethodName))
314
-        {
315
-            // Unable to find the requested object or method
316
-            $this->throwException('', 'errors.objects.invalid', $aErrorParams);
317
-        }
318
-
319
-        // Call the requested method
320
-        try
321
-        {
322
-            $sError = 'errors.objects.find';
323
-            /** @var CallableObject */
324
-            $xCallableObject = $this->getCallable($sClassName);
325
-
326
-            if($xCallableObject->excluded($sMethodName))
327
-            {
328
-                // Unable to find the requested class or method
329
-                $this->throwException('', 'errors.objects.excluded', $aErrorParams);
330
-            }
331
-
332
-            $sError = 'errors.objects.call';
333
-            $xCallableObject->call($this->xTarget);
334
-        }
335
-        catch(ReflectionException|SetupException $e)
336
-        {
337
-            // Unable to execute the requested class or method
338
-            $this->throwException($e->getMessage(), $sError, $aErrorParams);
339
-        }
340
-    }
305
+public function processRequest(): void
306
+{
307
+$sClassName = $this->xTarget->getClassName();
308
+$sMethodName = $this->xTarget->getMethodName();
309
+// Will be used to print a translated error message.
310
+$aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
311
+
312
+if(!$this->xValidator->validateJsObject($sClassName) ||
313
+!$this->xValidator->validateMethod($sMethodName))
314
+{
315
+// Unable to find the requested object or method
316
+$this->throwException('', 'errors.objects.invalid', $aErrorParams);
317
+}
318
+
319
+// Call the requested method
320
+try
321
+{
322
+$sError = 'errors.objects.find';
323
+/** @var CallableObject */
324
+$xCallableObject = $this->getCallable($sClassName);
325
+
326
+if($xCallableObject->excluded($sMethodName))
327
+{
328
+    // Unable to find the requested class or method
329
+    $this->throwException('', 'errors.objects.excluded', $aErrorParams);
330
+}
331
+
332
+$sError = 'errors.objects.call';
333
+$xCallableObject->call($this->xTarget);
334
+}
335
+catch(ReflectionException|SetupException $e)
336
+{
337
+// Unable to execute the requested class or method
338
+$this->throwException($e->getMessage(), $sError, $aErrorParams);
339
+}
340
+}
341 341
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -17 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function checkOptions(string $sCallable, $xOptions): array
89 89
     {
90
-        if(!$this->xValidator->validateClass(trim($sCallable)))
90
+        if (!$this->xValidator->validateClass(trim($sCallable)))
91 91
         {
92 92
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
93 93
         }
94
-        if(is_string($xOptions))
94
+        if (is_string($xOptions))
95 95
         {
96 96
             $xOptions = ['include' => $xOptions];
97 97
         }
98
-        elseif(!is_array($xOptions))
98
+        elseif (!is_array($xOptions))
99 99
         {
100 100
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
101 101
         }
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
     private function addCallable(CallableObject $xCallableObject): void
141 141
     {
142 142
         $aCallableMethods = $xCallableObject->getCallableMethods();
143
-        if($xCallableObject->excluded() || count($aCallableMethods) === 0)
143
+        if ($xCallableObject->excluded() || count($aCallableMethods) === 0)
144 144
         {
145 145
             return;
146 146
         }
147 147
 
148 148
         $aCallableObject = &$this->aCallableObjects;
149 149
         $sJsName = $xCallableObject->getJsName();
150
-        foreach(explode('.', $sJsName) as $sName)
150
+        foreach (explode('.', $sJsName) as $sName)
151 151
         {
152
-            if(!isset($aCallableObject['children'][$sName]))
152
+            if (!isset($aCallableObject['children'][$sName]))
153 153
             {
154 154
                 $aCallableObject['children'][$sName] = [];
155 155
             }
@@ -170,12 +170,11 @@  discard block
 block discarded – undo
170 170
     private function renderMethod(string $sIndent, array $aTemplateVars): string
171 171
     {
172 172
         $aOptions = [];
173
-        foreach($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
173
+        foreach ($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
174 174
         {
175 175
             $aOptions[] = "$sKey: $sValue";
176 176
         }
177
-        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' :
178
-            'args, { ' . implode(', ', $aOptions) . ' }';
177
+        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' : 'args, { ' . implode(', ', $aOptions) . ' }';
179 178
 
180 179
         return $sIndent . trim($this->xTemplateEngine
181 180
             ->render('jaxon::callables/method.js', $aTemplateVars));
@@ -197,11 +196,10 @@  discard block
 block discarded – undo
197 196
             'aMethod' => $aMethod,
198 197
             'nIndex' => $aCallable['index'] ?? 0,
199 198
         ]);
200
-        $aMethods = !isset($aCallable['methods']) ? [] :
201
-            array_map($fMethodCallback, $aCallable['methods']);
199
+        $aMethods = !isset($aCallable['methods']) ? [] : array_map($fMethodCallback, $aCallable['methods']);
202 200
 
203 201
         $aChildren = [];
204
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
202
+        foreach ($aCallable['children'] ?? [] as $sName => $aChild)
205 203
         {
206 204
             $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
207 205
                 $aChild, $nIndent) . ',';
@@ -243,7 +241,7 @@  discard block
 block discarded – undo
243 241
 
244 242
         $this->aCallableNames = [];
245 243
         $this->aCallableObjects = ['children' => []];
246
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
244
+        foreach ($this->cdi->getCallableObjects() as $xCallableObject)
247 245
         {
248 246
             $this->addCallable($xCallableObject);
249 247
         }
@@ -253,7 +251,7 @@  discard block
 block discarded – undo
253 251
                 'aCallableNames' => $this->aCallableNames,
254 252
             ])
255 253
         ];
256
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
254
+        foreach ($this->aCallableObjects['children'] as $sJsClass => $aCallable)
257 255
         {
258 256
             $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
259 257
                 $sJsClass, $aCallable) . ';';
@@ -309,7 +307,7 @@  discard block
 block discarded – undo
309 307
         // Will be used to print a translated error message.
310 308
         $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
311 309
 
312
-        if(!$this->xValidator->validateJsObject($sClassName) ||
310
+        if (!$this->xValidator->validateJsObject($sClassName) ||
313 311
             !$this->xValidator->validateMethod($sMethodName))
314 312
         {
315 313
             // Unable to find the requested object or method
@@ -323,7 +321,7 @@  discard block
 block discarded – undo
323 321
             /** @var CallableObject */
324 322
             $xCallableObject = $this->getCallable($sClassName);
325 323
 
326
-            if($xCallableObject->excluded($sMethodName))
324
+            if ($xCallableObject->excluded($sMethodName))
327 325
             {
328 326
                 // Unable to find the requested class or method
329 327
                 $this->throwException('', 'errors.objects.excluded', $aErrorParams);
@@ -332,7 +330,7 @@  discard block
 block discarded – undo
332 330
             $sError = 'errors.objects.call';
333 331
             $xCallableObject->call($this->xTarget);
334 332
         }
335
-        catch(ReflectionException|SetupException $e)
333
+        catch (ReflectionException|SetupException $e)
336 334
         {
337 335
             // Unable to execute the requested class or method
338 336
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
jaxon-core/src/Request/Upload/UploadHandlerInterface.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,45 +20,45 @@
 block discarded – undo
20 20
 
21 21
 interface UploadHandlerInterface
22 22
 {
23
-    /**
23
+/**
24 24
      * Set the uploaded file name sanitizer
25 25
      *
26 26
      * @param Closure $cSanitizer    The closure
27 27
      *
28 28
      * @return void
29 29
      */
30
-    public function sanitizer(Closure $cSanitizer);
30
+public function sanitizer(Closure $cSanitizer);
31 31
 
32
-    /**
32
+/**
33 33
      * Get the uploaded files
34 34
      *
35 35
      * @return FileInterface[]
36 36
      */
37
-    public function files(): array;
37
+public function files(): array;
38 38
 
39
-    /**
39
+/**
40 40
      * Check if the current request contains uploaded files
41 41
      *
42 42
      * @param ServerRequestInterface $xRequest
43 43
      *
44 44
      * @return bool
45 45
      */
46
-    public function canProcessRequest(ServerRequestInterface $xRequest): bool;
46
+public function canProcessRequest(ServerRequestInterface $xRequest): bool;
47 47
 
48
-    /**
48
+/**
49 49
      * Process the uploaded files in the HTTP request
50 50
      *
51 51
      * @param ServerRequestInterface $xRequest
52 52
      *
53 53
      * @return bool
54 54
      */
55
-    public function processRequest(ServerRequestInterface $xRequest): bool;
55
+public function processRequest(ServerRequestInterface $xRequest): bool;
56 56
 
57
-    /**
57
+/**
58 58
      * @param string $sStorage
59 59
      * @param Closure $cFactory
60 60
      *
61 61
      * @return void
62 62
      */
63
-    public function registerStorageAdapter(string $sStorage, Closure $cFactory);
63
+public function registerStorageAdapter(string $sStorage, Closure $cFactory);
64 64
 }
Please login to merge, or discard this patch.