Passed
Push — main ( 683317...8fa9e1 )
by Thierry
04:59
created
jaxon-core/src/App/Ajax/Traits/SendResponseTrait.php 1 patch
Switch Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -31,69 +31,69 @@
 block discarded – undo
31 31
 
32 32
 trait SendResponseTrait
33 33
 {
34
-    /**
34
+/**
35 35
      * @return Container
36 36
      */
37
-    abstract public function di(): Container;
37
+abstract public function di(): Container;
38 38
 
39
-    /**
39
+/**
40 40
      * @return ConfigManager
41 41
      */
42
-    abstract public function config(): ConfigManager;
42
+abstract public function config(): ConfigManager;
43 43
 
44
-    /**
44
+/**
45 45
      * @return Translator
46 46
      */
47
-    abstract public function translator(): Translator;
47
+abstract public function translator(): Translator;
48 48
 
49
-    /**
49
+/**
50 50
      * @return ResponseManager
51 51
      */
52
-    abstract public function getResponseManager(): ResponseManager;
52
+abstract public function getResponseManager(): ResponseManager;
53 53
 
54
-    /**
54
+/**
55 55
      * Prints the response to the output stream, thus sending the response to the browser
56 56
      *
57 57
      * @return mixed
58 58
      * @throws RequestException
59 59
      */
60
-    public function httpResponse(string $sCode = '200'): mixed
61
-    {
62
-        if(!$this->config()->getOption('core.response.send', false))
63
-        {
64
-            return null;
65
-        }
60
+public function httpResponse(string $sCode = '200'): mixed
61
+{
62
+if(!$this->config()->getOption('core.response.send', false))
63
+{
64
+return null;
65
+}
66 66
 
67
-        // Check to see if headers have already been sent out, in which case we can't do our job
68
-        if(headers_sent($sFilename, $nLineNumber))
69
-        {
70
-            throw new RequestException($this->translator()
71
-                ->trans('errors.output.already-sent', [
72
-                    'location' => "$sFilename:$nLineNumber",
73
-                ]) . "\n" . $this->translator()->trans('errors.output.advice'));
74
-        }
75
-        if(empty($sContent = $this->getResponseManager()->getOutput()))
76
-        {
77
-            return null;
78
-        }
67
+// Check to see if headers have already been sent out, in which case we can't do our job
68
+if(headers_sent($sFilename, $nLineNumber))
69
+{
70
+throw new RequestException($this->translator()
71
+    ->trans('errors.output.already-sent', [
72
+        'location' => "$sFilename:$nLineNumber",
73
+    ]) . "\n" . $this->translator()->trans('errors.output.advice'));
74
+}
75
+if(empty($sContent = $this->getResponseManager()->getOutput()))
76
+{
77
+return null;
78
+}
79 79
 
80
-        // Set the HTTP response code
81
-        http_response_code(intval($sCode));
80
+// Set the HTTP response code
81
+http_response_code(intval($sCode));
82 82
 
83
-        if($this->di()->getRequest()->getMethod() === 'GET')
84
-        {
85
-            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86
-            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
87
-            header("Cache-Control: no-cache, must-revalidate");
88
-            header("Pragma: no-cache");
89
-        }
90
-        header('Content-Type: ' . $this->getResponseManager()->getContentType());
83
+if($this->di()->getRequest()->getMethod() === 'GET')
84
+{
85
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
87
+header("Cache-Control: no-cache, must-revalidate");
88
+header("Pragma: no-cache");
89
+}
90
+header('Content-Type: ' . $this->getResponseManager()->getContentType());
91 91
 
92
-        print $sContent;
93
-        if($this->config()->getOption('core.process.exit', false))
94
-        {
95
-            exit();
96
-        }
97
-        return null;
98
-    }
92
+print $sContent;
93
+if($this->config()->getOption('core.process.exit', false))
94
+{
95
+exit();
96
+}
97
+return null;
98
+}
99 99
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/Traits/DiTrait.php 1 patch
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,41 +19,41 @@
 block discarded – undo
19 19
 
20 20
 trait DiTrait
21 21
 {
22
-    /**
22
+/**
23 23
      * @var Container
24 24
      */
25
-    private Container $xContainer;
25
+private Container $xContainer;
26 26
 
27
-    /**
27
+/**
28 28
      * @var ComponentContainer
29 29
      */
30
-    protected ComponentContainer $xComponentContainer;
30
+protected ComponentContainer $xComponentContainer;
31 31
 
32
-    /**
32
+/**
33 33
      * Get the DI container
34 34
      *
35 35
      * @return Container
36 36
      */
37
-    public function di(): Container
38
-    {
39
-        return $this->xContainer;
40
-    }
37
+public function di(): Container
38
+{
39
+return $this->xContainer;
40
+}
41 41
 
42
-    /**
42
+/**
43 43
      * Get the component DI container
44 44
      *
45 45
      * @return ComponentContainer
46 46
      */
47
-    public function cdi(): ComponentContainer
48
-    {
49
-        return $this->xComponentContainer;
50
-    }
47
+public function cdi(): ComponentContainer
48
+{
49
+return $this->xComponentContainer;
50
+}
51 51
 
52
-    /**
52
+/**
53 53
      * @return ConfigManager
54 54
      */
55
-    public function config(): ConfigManager
56
-    {
57
-        return $this->di()->g(ConfigManager::class);
58
-    }
55
+public function config(): ConfigManager
56
+{
57
+return $this->di()->g(ConfigManager::class);
58
+}
59 59
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/App.php 1 patch
Switch Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@
 block discarded – undo
21 21
 
22 22
 class App extends AbstractApp
23 23
 {
24
-    use Traits\SendResponseTrait;
24
+use Traits\SendResponseTrait;
25 25
 
26
-    /**
26
+/**
27 27
      * @inheritDoc
28 28
      * @throws SetupException
29 29
      */
30
-    public function setup(string $sConfigFile = ''): void
31
-    {
32
-        if(!file_exists($sConfigFile))
33
-        {
34
-            throw new SetupException($this->translator()
35
-                ->trans('errors.file.access', ['path' => $sConfigFile]));
36
-        }
37
-
38
-        // Read the config options.
39
-        $aOptions = $this->config()->read($sConfigFile);
40
-        $aLibOptions = $aOptions['lib'] ?? [];
41
-        $aAppOptions = $aOptions['app'] ?? [];
42
-        if(!is_array($aLibOptions) || !is_array($aAppOptions))
43
-        {
44
-            throw new SetupException($sMessage = $this->translator()
45
-                ->trans('errors.file.content', ['path' => $sConfigFile]));
46
-        }
47
-
48
-        // The bootstrap set this to false. It needs to be changed.
49
-        if(!isset($aLibOptions['core']['response']['send']))
50
-        {
51
-            $aLibOptions['core']['response']['send'] = true;
52
-        }
53
-
54
-        $this->bootstrap()
55
-            ->lib($aLibOptions)
56
-            ->app($aAppOptions)
57
-            ->setup();
58
-    }
30
+public function setup(string $sConfigFile = ''): void
31
+{
32
+if(!file_exists($sConfigFile))
33
+{
34
+throw new SetupException($this->translator()
35
+    ->trans('errors.file.access', ['path' => $sConfigFile]));
36
+}
37
+
38
+// Read the config options.
39
+$aOptions = $this->config()->read($sConfigFile);
40
+$aLibOptions = $aOptions['lib'] ?? [];
41
+$aAppOptions = $aOptions['app'] ?? [];
42
+if(!is_array($aLibOptions) || !is_array($aAppOptions))
43
+{
44
+throw new SetupException($sMessage = $this->translator()
45
+    ->trans('errors.file.content', ['path' => $sConfigFile]));
46
+}
47
+
48
+// The bootstrap set this to false. It needs to be changed.
49
+if(!isset($aLibOptions['core']['response']['send']))
50
+{
51
+$aLibOptions['core']['response']['send'] = true;
52
+}
53
+
54
+$this->bootstrap()
55
+->lib($aLibOptions)
56
+->app($aAppOptions)
57
+->setup();
58
+}
59 59
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/AppInterface.php 1 patch
Switch Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,58 +22,58 @@  discard block
 block discarded – undo
22 22
 
23 23
 interface AppInterface
24 24
 {
25
-    /**
25
+/**
26 26
      * Set the logger.
27 27
      *
28 28
      * @param LoggerInterface|Closure $xLogger
29 29
      *
30 30
      * @return void
31 31
      */
32
-    public function setLogger(LoggerInterface|Closure $xLogger): void;
32
+public function setLogger(LoggerInterface|Closure $xLogger): void;
33 33
 
34
-    /**
34
+/**
35 35
      * Get the configured character encoding
36 36
      *
37 37
      * @return string
38 38
      */
39
-    public function getCharacterEncoding(): string;
39
+public function getCharacterEncoding(): string;
40 40
 
41
-    /**
41
+/**
42 42
      * Get the content type of the HTTP response
43 43
      *
44 44
      * @return string
45 45
      */
46
-    public function getContentType(): string;
46
+public function getContentType(): string;
47 47
 
48
-    /**
48
+/**
49 49
      * Get the HTML tags to include Jaxon javascript files into the page.
50 50
      *
51 51
      * @return string
52 52
      */
53
-    public function getJs(): string;
53
+public function getJs(): string;
54 54
 
55
-    /**
55
+/**
56 56
      * Get the HTML tags to include Jaxon javascript files into the page.
57 57
      *
58 58
      * @return string  the javascript code
59 59
      */
60
-    public function js(): string;
60
+public function js(): string;
61 61
 
62
-    /**
62
+/**
63 63
      * Get the HTML tags to include Jaxon CSS code and files into the page.
64 64
      *
65 65
      * @return string
66 66
      */
67
-    public function getCss(): string;
67
+public function getCss(): string;
68 68
 
69
-    /**
69
+/**
70 70
      * Get the HTML tags to include Jaxon CSS code and files into the page.
71 71
      *
72 72
      * @return string  the javascript code
73 73
      */
74
-    public function css(): string;
74
+public function css(): string;
75 75
 
76
-    /**
76
+/**
77 77
      * Returns the js header and wrapper code to be printed into the page
78 78
      *
79 79
      * The javascript code returned by this function is dependent on the plugins
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      *
85 85
      * @return string
86 86
      */
87
-    public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string;
87
+public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string;
88 88
 
89
-    /**
89
+/**
90 90
      * Returns the js header and wrapper code to be printed into the page
91 91
      *
92 92
      * @param bool $bIncludeJs    Also get the JS files
@@ -95,46 +95,46 @@  discard block
 block discarded – undo
95 95
      * @return string  the javascript code
96 96
      * @throws UriException
97 97
      */
98
-    public function script(bool $bIncludeJs = false, bool $bIncludeCss = false): string;
98
+public function script(bool $bIncludeJs = false, bool $bIncludeCss = false): string;
99 99
 
100
-    /**
100
+/**
101 101
      * Determine if a call is a jaxon request or a page load request
102 102
      *
103 103
      * @return bool
104 104
      */
105
-    public function canProcessRequest(): bool;
105
+public function canProcessRequest(): bool;
106 106
 
107
-    /**
107
+/**
108 108
      * Process an incoming Jaxon request, and return the response.
109 109
      *
110 110
      * @return mixed
111 111
      */
112
-    public function processRequest(): mixed;
112
+public function processRequest(): mixed;
113 113
 
114
-    /**
114
+/**
115 115
      * Get the Jaxon ajax response
116 116
      *
117 117
      * @return AjaxResponse
118 118
      */
119
-    public function ajaxResponse(): AjaxResponse;
119
+public function ajaxResponse(): AjaxResponse;
120 120
 
121
-    /**
121
+/**
122 122
      * @param Closure $xClosure    A closure to create the session manager instance
123 123
      *
124 124
      * @return void
125 125
      */
126
-    public function setSessionManager(Closure $xClosure);
126
+public function setSessionManager(Closure $xClosure);
127 127
 
128
-    /**
128
+/**
129 129
      * Set the container provided by the integrated framework
130 130
      *
131 131
      * @param ContainerInterface $xContainer    The container implementation
132 132
      *
133 133
      * @return void
134 134
      */
135
-    public function setContainer(ContainerInterface $xContainer);
135
+public function setContainer(ContainerInterface $xContainer);
136 136
 
137
-    /**
137
+/**
138 138
      * Add a view renderer with an id
139 139
      *
140 140
      * @param string $sRenderer    The renderer name
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @return void
145 145
      */
146
-    public function addViewRenderer(string $sRenderer, string $sExtension, Closure $xClosure);
146
+public function addViewRenderer(string $sRenderer, string $sExtension, Closure $xClosure);
147 147
 
148
-    /**
148
+/**
149 149
      * Set the javascript asset
150 150
      *
151 151
      * @param bool $bExport    Whether to export the js code in a file
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @return void
157 157
      */
158
-    public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): void;
158
+public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): void;
159 159
 
160
-    /**
160
+/**
161 161
      * Read config options from a config file and set up the library
162 162
      *
163 163
      * @param string $sConfigFile    The full path to the config file
164 164
      *
165 165
      * @return void
166 166
      */
167
-    public function setup(string $sConfigFile = ''): void;
167
+public function setup(string $sConfigFile = ''): void;
168 168
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Ajax/AbstractApp.php 1 patch
Switch Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -20,32 +20,32 @@  discard block
 block discarded – undo
20 20
 
21 21
 abstract class AbstractApp implements AppInterface
22 22
 {
23
-    use Traits\ServicesTrait;
24
-    use Traits\PluginTrait;
25
-    use Traits\RequestTrait;
26
-    use Traits\ResponseTrait;
23
+use Traits\ServicesTrait;
24
+use Traits\PluginTrait;
25
+use Traits\RequestTrait;
26
+use Traits\ResponseTrait;
27 27
 
28
-    /**
28
+/**
29 29
      * The class constructor
30 30
      */
31
-    public function __construct()
32
-    {
33
-        // Declared in DiTrait.
34
-        $this->xContainer = Jaxon::getInstance()->di();
35
-        $this->xComponentContainer = Jaxon::getInstance()->cdi();
36
-    }
31
+public function __construct()
32
+{
33
+// Declared in DiTrait.
34
+$this->xContainer = Jaxon::getInstance()->di();
35
+$this->xComponentContainer = Jaxon::getInstance()->cdi();
36
+}
37 37
 
38
-    /**
38
+/**
39 39
      * Get the Jaxon application bootstrapper.
40 40
      *
41 41
      * @return Bootstrap
42 42
      */
43
-    protected function bootstrap(): Bootstrap
44
-    {
45
-        return $this->xContainer->getBootstrap();
46
-    }
43
+protected function bootstrap(): Bootstrap
44
+{
45
+return $this->xContainer->getBootstrap();
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * Set the javascript asset
50 50
      *
51 51
      * @param bool $bExport    Whether to export the js code in a file
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): void
59
-    {
60
-        $this->bootstrap()->asset($bExport, $bMinify, $sUri, $sDir);
61
-    }
58
+public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''): void
59
+{
60
+$this->bootstrap()->asset($bExport, $bMinify, $sUri, $sDir);
61
+}
62 62
 
63
-    /**
63
+/**
64 64
      * Set the container provided by the integrated framework
65 65
      *
66 66
      * @param ContainerInterface $xContainer    The container implementation
67 67
      *
68 68
      * @return void
69 69
      */
70
-    public function setContainer(ContainerInterface $xContainer): void
71
-    {
72
-        $this->di()->setContainer($xContainer);
73
-    }
70
+public function setContainer(ContainerInterface $xContainer): void
71
+{
72
+$this->di()->setContainer($xContainer);
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @inheritDoc
77 77
      */
78
-    public function setup(string $sConfigFile = ''): void
79
-    {}
78
+public function setup(string $sConfigFile = ''): void
79
+{}
80 80
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/ViewInterface.php 1 patch
Switch Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 interface ViewInterface
6 6
 {
7
-    /**
7
+/**
8 8
      * Add a namespace to the view renderer
9 9
      *
10 10
      * @param string $sNamespace    The namespace name
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      *
14 14
      * @return void
15 15
      */
16
-    public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void;
16
+public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void;
17 17
 
18
-    /**
18
+/**
19 19
      * Render a view
20 20
      *
21 21
      * @param Store $store    A store populated with the view data
22 22
      *
23 23
      * @return string
24 24
      */
25
-    public function render(Store $store): string;
25
+public function render(Store $store): string;
26 26
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/Helper/EventAttr.php 1 patch
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
 
24 24
 class EventAttr
25 25
 {
26
-    /**
26
+/**
27 27
      * @var array
28 28
      */
29
-    private array $aHandlers = [];
29
+private array $aHandlers = [];
30 30
 
31
-    /**
31
+/**
32 32
      * The constructor
33 33
      *
34 34
      * @param string $sSelector
35 35
      */
36
-    public function __construct(private string $sSelector)
37
-    {}
36
+public function __construct(private string $sSelector)
37
+{}
38 38
 
39
-    /**
39
+/**
40 40
      * Set a selector for the next event handler
41 41
      *
42 42
      * @param string $sSelector
43 43
      *
44 44
      * @return self
45 45
      */
46
-    public function select(string $sSelector): self
47
-    {
48
-        $this->sSelector = trim($sSelector);
49
-        return $this;
50
-    }
46
+public function select(string $sSelector): self
47
+{
48
+$this->sSelector = trim($sSelector);
49
+return $this;
50
+}
51 51
 
52
-    /**
52
+/**
53 53
      * Set an event handler with the "on" keyword
54 54
      *
55 55
      * @param string $event
@@ -57,43 +57,43 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return self
59 59
      */
60
-    public function on(string $event, JsExpr $xJsExpr): self
61
-    {
62
-        if($this->sSelector === '')
63
-        {
64
-            return $this;
65
-        }
60
+public function on(string $event, JsExpr $xJsExpr): self
61
+{
62
+if($this->sSelector === '')
63
+{
64
+return $this;
65
+}
66 66
 
67
-        $this->aHandlers[] = [
68
-            'select' => $this->sSelector,
69
-            'event' => trim($event),
70
-            'handler' => $xJsExpr,
71
-        ];
72
-        $this->sSelector = '';
73
-        return $this;
74
-    }
67
+$this->aHandlers[] = [
68
+'select' => $this->sSelector,
69
+'event' => trim($event),
70
+'handler' => $xJsExpr,
71
+];
72
+$this->sSelector = '';
73
+return $this;
74
+}
75 75
 
76
-    /**
76
+/**
77 77
      * Shortcut to set a click event handler
78 78
      *
79 79
      * @param JsExpr $xJsExpr
80 80
      *
81 81
      * @return self
82 82
      */
83
-    public function click(JsExpr $xJsExpr): self
84
-    {
85
-        return $this->on('click', $xJsExpr);
86
-    }
83
+public function click(JsExpr $xJsExpr): self
84
+{
85
+return $this->on('click', $xJsExpr);
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * Convert to string.
90 90
      *
91 91
      * @return string
92 92
      */
93
-    public function __toString(): string
94
-    {
95
-        // No output if no handler is defined.
96
-        return count($this->aHandlers) === 0 ? '' : 'jxn-event="' .
97
-            htmlentities(json_encode($this->aHandlers)) . '"';
98
-    }
93
+public function __toString(): string
94
+{
95
+// No output if no handler is defined.
96
+return count($this->aHandlers) === 0 ? '' : 'jxn-event="' .
97
+htmlentities(json_encode($this->aHandlers)) . '"';
98
+}
99 99
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/Helper/HtmlAttrHelper.php 1 patch
Switch Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 
32 32
 class HtmlAttrHelper
33 33
 {
34
-    /**
34
+/**
35 35
      * @var string|null
36 36
      */
37
-    private string|null $sPaginationComponent = null;
37
+private string|null $sPaginationComponent = null;
38 38
 
39
-    /**
39
+/**
40 40
      * The constructor
41 41
      *
42 42
      * @param ComponentContainer $cdi
43 43
      */
44
-    public function __construct(protected ComponentContainer $cdi)
45
-    {}
44
+public function __construct(protected ComponentContainer $cdi)
45
+{}
46 46
 
47
-    /**
47
+/**
48 48
      * Get the component HTML code
49 49
      *
50 50
      * @param JxnCall $xJsCall
51 51
      *
52 52
      * @return string
53 53
      */
54
-    public function html(JxnCall $xJsCall): string
55
-    {
56
-        $sClassName = $xJsCall->_class();
57
-        if(!$sClassName)
58
-        {
59
-            return '';
60
-        }
61
-
62
-        $xComponent = $this->cdi->makeComponent($sClassName);
63
-        return is_a($xComponent, NodeComponent::class) ?
64
-            (string)$xComponent->html() : '';
65
-    }
66
-
67
-    /**
54
+public function html(JxnCall $xJsCall): string
55
+{
56
+$sClassName = $xJsCall->_class();
57
+if(!$sClassName)
58
+{
59
+return '';
60
+}
61
+
62
+$xComponent = $this->cdi->makeComponent($sClassName);
63
+return is_a($xComponent, NodeComponent::class) ?
64
+(string)$xComponent->html() : '';
65
+}
66
+
67
+/**
68 68
      * Attach a component to a DOM node
69 69
      *
70 70
      * @param JxnCall $xJsCall
@@ -72,41 +72,41 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return string
74 74
      */
75
-    public function bind(JxnCall $xJsCall, string $item = ''): string
76
-    {
77
-        $item = trim($item);
78
-        return 'jxn-bind="' . $xJsCall->_class() . (!$item ? '"' : '" jxn-item="' . $item . '"');
79
-    }
75
+public function bind(JxnCall $xJsCall, string $item = ''): string
76
+{
77
+$item = trim($item);
78
+return 'jxn-bind="' . $xJsCall->_class() . (!$item ? '"' : '" jxn-item="' . $item . '"');
79
+}
80 80
 
81
-    /**
81
+/**
82 82
      * Attach the pagination component to a DOM node
83 83
      *
84 84
      * @param JxnCall $xJsCall
85 85
      *
86 86
      * @return string
87 87
      */
88
-    public function pagination(JxnCall $xJsCall): string
89
-    {
90
-        // The pagination is always rendered with the same Pagination component.
91
-        $sComponent = $this->sPaginationComponent ?:
92
-            ($this->sPaginationComponent = rq(Pagination::class)->_class());
93
-        $sItem = $xJsCall->_class();
94
-        return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\"";
95
-    }
96
-
97
-    /**
88
+public function pagination(JxnCall $xJsCall): string
89
+{
90
+// The pagination is always rendered with the same Pagination component.
91
+$sComponent = $this->sPaginationComponent ?:
92
+($this->sPaginationComponent = rq(Pagination::class)->_class());
93
+$sItem = $xJsCall->_class();
94
+return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\"";
95
+}
96
+
97
+/**
98 98
      * Set a selector for the next event handler
99 99
      *
100 100
      * @param string $sSelector
101 101
      *
102 102
      * @return EventAttr
103 103
      */
104
-    public function select(string $sSelector): EventAttr
105
-    {
106
-        return new EventAttr($sSelector);
107
-    }
104
+public function select(string $sSelector): EventAttr
105
+{
106
+return new EventAttr($sSelector);
107
+}
108 108
 
109
-    /**
109
+/**
110 110
      * Set an event handler
111 111
      *
112 112
      * @param string $event
@@ -114,83 +114,83 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @return string
116 116
      */
117
-    public function on(string $event, JsExpr $xJsExpr): string
118
-    {
119
-        $event = trim($event);
120
-        $sCall = htmlentities(json_encode($xJsExpr->jsonSerialize()));
121
-        return "jxn-on=\"$event\" jxn-call=\"$sCall\"";
122
-    }
123
-
124
-    /**
117
+public function on(string $event, JsExpr $xJsExpr): string
118
+{
119
+$event = trim($event);
120
+$sCall = htmlentities(json_encode($xJsExpr->jsonSerialize()));
121
+return "jxn-on=\"$event\" jxn-call=\"$sCall\"";
122
+}
123
+
124
+/**
125 125
      * Shortcut to set a click event handler
126 126
      *
127 127
      * @param JsExpr $xJsExpr
128 128
      *
129 129
      * @return string
130 130
      */
131
-    public function click(JsExpr $xJsExpr): string
132
-    {
133
-        return $this->on('click', $xJsExpr);
134
-    }
131
+public function click(JsExpr $xJsExpr): string
132
+{
133
+return $this->on('click', $xJsExpr);
134
+}
135 135
 
136
-    /**
136
+/**
137 137
      * @param array $aHandler
138 138
      *
139 139
      * @return bool
140 140
      */
141
-    private function eventIsValid(array $aHandler): bool
142
-    {
143
-        return count($aHandler) === 3 &&
144
-            isset($aHandler[0]) && isset($aHandler[1]) && isset($aHandler[2]) &&
145
-            is_string($aHandler[0]) && is_string($aHandler[1]) &&
146
-            is_a($aHandler[2], JsExpr::class);
147
-    }
148
-
149
-    /**
141
+private function eventIsValid(array $aHandler): bool
142
+{
143
+return count($aHandler) === 3 &&
144
+isset($aHandler[0]) && isset($aHandler[1]) && isset($aHandler[2]) &&
145
+is_string($aHandler[0]) && is_string($aHandler[1]) &&
146
+is_a($aHandler[2], JsExpr::class);
147
+}
148
+
149
+/**
150 150
      * @param array $aHandler
151 151
      * @param EventAttr|null $xAttr
152 152
      *
153 153
      * @return EventAttr|null
154 154
      */
155
-    private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null
156
-    {
157
-        if(!$this->eventIsValid($aHandler))
158
-        {
159
-            return $xAttr;
160
-        }
161
-        // The array content is valid.
162
-        [$sSelector, $sEvent, $xJsExpr] = $aHandler;
163
-        return !$xAttr ?
164
-            $this->select($sSelector)->on($sEvent, $xJsExpr) :
165
-            $xAttr->select($sSelector)->on($sEvent, $xJsExpr);
166
-    }
167
-
168
-    /**
155
+private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null
156
+{
157
+if(!$this->eventIsValid($aHandler))
158
+{
159
+return $xAttr;
160
+}
161
+// The array content is valid.
162
+[$sSelector, $sEvent, $xJsExpr] = $aHandler;
163
+return !$xAttr ?
164
+$this->select($sSelector)->on($sEvent, $xJsExpr) :
165
+$xAttr->select($sSelector)->on($sEvent, $xJsExpr);
166
+}
167
+
168
+/**
169 169
      * Set an event handler
170 170
      *
171 171
      * @param array $aHandler
172 172
      *
173 173
      * @return string
174 174
      */
175
-    public function event(array $aHandler): string
176
-    {
177
-        return $this->setEventHandler($aHandler)?->__toString() ?? '';
178
-    }
175
+public function event(array $aHandler): string
176
+{
177
+return $this->setEventHandler($aHandler)?->__toString() ?? '';
178
+}
179 179
 
180
-    /**
180
+/**
181 181
      * Set event handlers
182 182
      *
183 183
      * @param array $aHandlers
184 184
      *
185 185
      * @return string
186 186
      */
187
-    public function events(array $aHandlers): string
188
-    {
189
-        return array_reduce($aHandlers, fn(EventAttr|null $xAttr, array $aHandler)
190
-            => $this->setEventHandler($aHandler, $xAttr), null)?->__toString() ?? '';
191
-    }
187
+public function events(array $aHandlers): string
188
+{
189
+return array_reduce($aHandlers, fn(EventAttr|null $xAttr, array $aHandler)
190
+=> $this->setEventHandler($aHandler, $xAttr), null)?->__toString() ?? '';
191
+}
192 192
 
193
-    /**
193
+/**
194 194
      * Get the HTML or Javascript ready code for a package
195 195
      *
196 196
      * @param string $sClass
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
      *
199 199
      * @return string
200 200
      */
201
-    public function package(string $sClass, string $sType = 'html'): string
202
-    {
203
-        $sCode = match($sType) {
204
-            'html' => jaxon()->package($sClass)?->getHtml() ?? '',
205
-            'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '',
206
-            default => ''
207
-        };
208
-        $sCode = trim($sCode);
209
-
210
-        return $sType !== 'ready' || $sCode === '' ? $sCode :
211
-            // Call the ready code with the jaxon.dom.ready function.
212
-            "jaxon.dom.ready(() => $sCode)";
213
-    }
201
+public function package(string $sClass, string $sType = 'html'): string
202
+{
203
+$sCode = match($sType) {
204
+'html' => jaxon()->package($sClass)?->getHtml() ?? '',
205
+'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '',
206
+default => ''
207
+};
208
+$sCode = trim($sCode);
209
+
210
+return $sType !== 'ready' || $sCode === '' ? $sCode :
211
+// Call the ready code with the jaxon.dom.ready function.
212
+"jaxon.dom.ready(() => $sCode)";
213
+}
214 214
 }
Please login to merge, or discard this patch.
jaxon-annotations/src/Annotation/ExportAnnotation.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,41 +26,41 @@
 block discarded – undo
26 26
  */
27 27
 class ExportAnnotation extends AbstractAnnotation
28 28
 {
29
-    /**
29
+/**
30 30
      * @var array
31 31
      */
32
-    private $aMethods = [];
32
+private $aMethods = [];
33 33
 
34
-    /**
34
+/**
35 35
      * @inheritDoc
36 36
      */
37
-    public static function parseAnnotation($value)
38
-    {
39
-        $aParams = json_decode($value, true);
40
-        return is_array($aParams) ? $aParams : [];
41
-    }
37
+public static function parseAnnotation($value)
38
+{
39
+$aParams = json_decode($value, true);
40
+return is_array($aParams) ? $aParams : [];
41
+}
42 42
 
43
-    /**
43
+/**
44 44
      * @inheritDoc
45 45
      * @throws AnnotationException
46 46
      */
47
-    public function initAnnotation(array $properties)
48
-    {
49
-        foreach(['base', 'only', 'except'] as $key)
50
-        {
51
-            if(isset($properties[$key]) && is_array($properties[$key]) &&
52
-                count($properties[$key]) > 0)
53
-            {
54
-                $this->aMethods[$key] = $properties[$key];
55
-            }
56
-        }
57
-    }
47
+public function initAnnotation(array $properties)
48
+{
49
+foreach(['base', 'only', 'except'] as $key)
50
+{
51
+if(isset($properties[$key]) && is_array($properties[$key]) &&
52
+    count($properties[$key]) > 0)
53
+{
54
+    $this->aMethods[$key] = $properties[$key];
55
+}
56
+}
57
+}
58 58
 
59
-    /**
59
+/**
60 60
      * @inheritDoc
61 61
      */
62
-    public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
63
-    {
64
-        $xMetadata->export($sMethod)->setMethods($this->aMethods);
65
-    }
62
+public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
63
+{
64
+$xMetadata->export($sMethod)->setMethods($this->aMethods);
65
+}
66 66
 }
Please login to merge, or discard this patch.