Passed
Push — main ( 683317...8fa9e1 )
by Thierry
04:59
created
jaxon-utils/tests/TestTranslator/TranslatorTest.php 1 patch
Switch Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -7,87 +7,87 @@
 block discarded – undo
7 7
 
8 8
 final class TranslatorTest extends TestCase
9 9
 {
10
-    /**
10
+/**
11 11
      * @var Translator
12 12
      */
13
-    protected $xTranslator;
13
+protected $xTranslator;
14 14
 
15
-    protected function setUp(): void
16
-    {
17
-        $this->xTranslator = new Translator();
18
-        $this->xTranslator->loadTranslations(__DIR__ . '/../translations/test.en.php', 'en');
19
-        $this->xTranslator->loadTranslations(__DIR__ . '/../translations/test.fr.php', 'fr');
20
-    }
15
+protected function setUp(): void
16
+{
17
+$this->xTranslator = new Translator();
18
+$this->xTranslator->loadTranslations(__DIR__ . '/../translations/test.en.php', 'en');
19
+$this->xTranslator->loadTranslations(__DIR__ . '/../translations/test.fr.php', 'fr');
20
+}
21 21
 
22
-    public function testFileWithBadData()
23
-    {
24
-        $this->assertFalse($this->xTranslator->loadTranslations(__DIR__ . '/../translations/error.php', 'en'));
25
-    }
22
+public function testFileWithBadData()
23
+{
24
+$this->assertFalse($this->xTranslator->loadTranslations(__DIR__ . '/../translations/error.php', 'en'));
25
+}
26 26
 
27
-    public function testFileNotFound()
28
-    {
29
-        $this->assertFalse($this->xTranslator->loadTranslations(__DIR__ . '/../translations/not-found.php', 'en'));
30
-    }
27
+public function testFileNotFound()
28
+{
29
+$this->assertFalse($this->xTranslator->loadTranslations(__DIR__ . '/../translations/not-found.php', 'en'));
30
+}
31 31
 
32
-    public function testMissingEnTranslations()
33
-    {
34
-        $this->xTranslator->setLocale('en');
35
-        $this->assertEquals('salutations.hello', $this->xTranslator->trans('salutations.hello'));
36
-    }
32
+public function testMissingEnTranslations()
33
+{
34
+$this->xTranslator->setLocale('en');
35
+$this->assertEquals('salutations.hello', $this->xTranslator->trans('salutations.hello'));
36
+}
37 37
 
38
-    public function testMissingFrTranslations()
39
-    {
40
-        $this->xTranslator->setLocale('fr');
41
-        $this->assertEquals('salutations.hello', $this->xTranslator->trans('salutations.hello'));
42
-    }
38
+public function testMissingFrTranslations()
39
+{
40
+$this->xTranslator->setLocale('fr');
41
+$this->assertEquals('salutations.hello', $this->xTranslator->trans('salutations.hello'));
42
+}
43 43
 
44
-    public function testSimpleEnTranslations()
45
-    {
46
-        $this->xTranslator->setLocale('en');
47
-        $this->assertEquals('Good morning', $this->xTranslator->trans('salutations.morning'));
48
-        $this->assertEquals('Good afternoon', $this->xTranslator->trans('salutations.afternoon'));
49
-    }
44
+public function testSimpleEnTranslations()
45
+{
46
+$this->xTranslator->setLocale('en');
47
+$this->assertEquals('Good morning', $this->xTranslator->trans('salutations.morning'));
48
+$this->assertEquals('Good afternoon', $this->xTranslator->trans('salutations.afternoon'));
49
+}
50 50
 
51
-    public function testSimpleFrTranslations()
52
-    {
53
-        $this->xTranslator->setLocale('fr');
54
-        $this->assertEquals('Bonjour', $this->xTranslator->trans('salutations.morning'));
55
-        $this->assertEquals('Bonsoir', $this->xTranslator->trans('salutations.afternoon'));
56
-    }
51
+public function testSimpleFrTranslations()
52
+{
53
+$this->xTranslator->setLocale('fr');
54
+$this->assertEquals('Bonjour', $this->xTranslator->trans('salutations.morning'));
55
+$this->assertEquals('Bonsoir', $this->xTranslator->trans('salutations.afternoon'));
56
+}
57 57
 
58
-    public function testEnTranslationsWithPlaceholders()
59
-    {
60
-        $this->xTranslator->setLocale('en');
61
-        $this->assertEquals('Good morning Mr. Johnson',
62
-            $this->xTranslator->trans('placeholders.morning', ['title' => 'Mr.', 'name' => 'Johnson']));
63
-        $this->assertEquals('Good afternoon Mrs. Smith',
64
-            $this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mrs.', 'name' => 'Smith']));
65
-    }
58
+public function testEnTranslationsWithPlaceholders()
59
+{
60
+$this->xTranslator->setLocale('en');
61
+$this->assertEquals('Good morning Mr. Johnson',
62
+$this->xTranslator->trans('placeholders.morning', ['title' => 'Mr.', 'name' => 'Johnson']));
63
+$this->assertEquals('Good afternoon Mrs. Smith',
64
+$this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mrs.', 'name' => 'Smith']));
65
+}
66 66
 
67
-    public function testFrTranslationsWithPlaceholders()
68
-    {
69
-        $this->xTranslator->setLocale('fr');
70
-        $this->assertEquals('Bonjour M. Pierre',
71
-            $this->xTranslator->trans('placeholders.morning', ['title' => 'M.', 'name' => 'Pierre']));
72
-        $this->assertEquals('Bonsoir Mme Paule',
73
-            $this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mme', 'name' => 'Paule']));
74
-    }
67
+public function testFrTranslationsWithPlaceholders()
68
+{
69
+$this->xTranslator->setLocale('fr');
70
+$this->assertEquals('Bonjour M. Pierre',
71
+$this->xTranslator->trans('placeholders.morning', ['title' => 'M.', 'name' => 'Pierre']));
72
+$this->assertEquals('Bonsoir Mme Paule',
73
+$this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mme', 'name' => 'Paule']));
74
+}
75 75
 
76
-    public function testExplicitEnTranslations()
77
-    {
78
-        $this->xTranslator->setLocale('fr');
79
-        $this->assertEquals('Good morning Mr. Johnson',
80
-            $this->xTranslator->trans('placeholders.morning', ['title' => 'Mr.', 'name' => 'Johnson'], 'en'));
81
-        $this->assertEquals('Good afternoon Mrs. Smith',
82
-            $this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mrs.', 'name' => 'Smith'], 'en'));
83
-    }
76
+public function testExplicitEnTranslations()
77
+{
78
+$this->xTranslator->setLocale('fr');
79
+$this->assertEquals('Good morning Mr. Johnson',
80
+$this->xTranslator->trans('placeholders.morning', ['title' => 'Mr.', 'name' => 'Johnson'], 'en'));
81
+$this->assertEquals('Good afternoon Mrs. Smith',
82
+$this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mrs.', 'name' => 'Smith'], 'en'));
83
+}
84 84
 
85
-    public function testExplicitFrTranslations()
86
-    {
87
-        $this->xTranslator->setLocale('en');
88
-        $this->assertEquals('Bonjour M. Pierre',
89
-            $this->xTranslator->trans('placeholders.morning', ['title' => 'M.', 'name' => 'Pierre'], 'fr'));
90
-        $this->assertEquals('Bonsoir Mme Paule',
91
-            $this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mme', 'name' => 'Paule'], 'fr'));
92
-    }
85
+public function testExplicitFrTranslations()
86
+{
87
+$this->xTranslator->setLocale('en');
88
+$this->assertEquals('Bonjour M. Pierre',
89
+$this->xTranslator->trans('placeholders.morning', ['title' => 'M.', 'name' => 'Pierre'], 'fr'));
90
+$this->assertEquals('Bonsoir Mme Paule',
91
+$this->xTranslator->trans('placeholders.afternoon', ['title' => 'Mme', 'name' => 'Paule'], 'fr'));
92
+}
93 93
 }
Please login to merge, or discard this patch.
jaxon-utils/tests/translations/test.en.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    'salutations' => [
5
-        'morning' => "Good morning",
6
-        'afternoon' => "Good afternoon",
7
-    ],
8
-    'placeholders' => [
9
-        'morning' => "Good morning :title :name",
10
-        'afternoon' => "Good afternoon :title :name",
11
-    ],
4
+'salutations' => [
5
+'morning' => "Good morning",
6
+'afternoon' => "Good afternoon",
7
+],
8
+'placeholders' => [
9
+'morning' => "Good morning :title :name",
10
+'afternoon' => "Good afternoon :title :name",
11
+],
12 12
 ];
Please login to merge, or discard this patch.
jaxon-utils/tests/translations/test.fr.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    'salutations' => [
5
-        'morning' => "Bonjour",
6
-        'afternoon' => "Bonsoir",
7
-    ],
8
-    'placeholders' => [
9
-        'morning' => "Bonjour :title :name",
10
-        'afternoon' => "Bonsoir :title :name",
11
-    ],
4
+'salutations' => [
5
+'morning' => "Bonjour",
6
+'afternoon' => "Bonsoir",
7
+],
8
+'placeholders' => [
9
+'morning' => "Bonjour :title :name",
10
+'afternoon' => "Bonsoir :title :name",
11
+],
12 12
 ];
Please login to merge, or discard this patch.
jaxon-utils/tests/TestUriDetector/UriDetectorTest.php 1 patch
Switch Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -8,202 +8,202 @@
 block discarded – undo
8 8
 
9 9
 final class UriDetectorTest extends TestCase
10 10
 {
11
-    /**
11
+/**
12 12
      * @var UriDetector
13 13
      */
14
-    protected $xUriDetector;
14
+protected $xUriDetector;
15 15
 
16
-    protected function setUp(): void
17
-    {
18
-        $this->xUriDetector = new UriDetector();
19
-    }
16
+protected function setUp(): void
17
+{
18
+$this->xUriDetector = new UriDetector();
19
+}
20 20
 
21
-    /**
21
+/**
22 22
      * @throws UriException
23 23
      */
24
-    public function testUri()
25
-    {
26
-        $this->assertEquals('http://example.test/path', $this->xUriDetector->detect([
27
-            'REQUEST_URI' => 'http://example.test/path'
28
-        ]));
29
-    }
30
-
31
-    /**
24
+public function testUri()
25
+{
26
+$this->assertEquals('http://example.test/path', $this->xUriDetector->detect([
27
+'REQUEST_URI' => 'http://example.test/path'
28
+]));
29
+}
30
+
31
+/**
32 32
      * @throws UriException
33 33
      */
34
-    public function testUriWithParam()
35
-    {
36
-        $this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
37
-            $this->xUriDetector->detect([
38
-                'REQUEST_URI' => 'http://example.test/path?param1=value1&param2="value2"',
39
-            ])
40
-        );
41
-    }
42
-
43
-    /**
34
+public function testUriWithParam()
35
+{
36
+$this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
37
+$this->xUriDetector->detect([
38
+    'REQUEST_URI' => 'http://example.test/path?param1=value1&param2="value2"',
39
+])
40
+);
41
+}
42
+
43
+/**
44 44
      * @throws UriException
45 45
      */
46
-    public function testUriWithUser()
47
-    {
48
-        $this->assertEquals('http://[email protected]/path', $this->xUriDetector->detect([
49
-            'REQUEST_URI' => 'http://[email protected]/path'
50
-        ]));
51
-    }
52
-
53
-    /**
46
+public function testUriWithUser()
47
+{
48
+$this->assertEquals('http://[email protected]/path', $this->xUriDetector->detect([
49
+'REQUEST_URI' => 'http://[email protected]/path'
50
+]));
51
+}
52
+
53
+/**
54 54
      * @throws UriException
55 55
      */
56
-    public function testUriWithUserAndPass()
57
-    {
58
-        $this->assertEquals('http://user:[email protected]/path', $this->xUriDetector->detect([
59
-            'REQUEST_URI' => 'http://user:[email protected]/path'
60
-        ]));
61
-    }
62
-
63
-    /**
56
+public function testUriWithUserAndPass()
57
+{
58
+$this->assertEquals('http://user:[email protected]/path', $this->xUriDetector->detect([
59
+'REQUEST_URI' => 'http://user:[email protected]/path'
60
+]));
61
+}
62
+
63
+/**
64 64
      * @throws UriException
65 65
      */
66
-    public function testUriWithEmptyBasename()
67
-    {
68
-        $this->assertEquals('http://example.test/', $this->xUriDetector->detect([
69
-            'REQUEST_URI' => 'http://example.test//'
70
-        ]));
71
-    }
72
-
73
-    /**
66
+public function testUriWithEmptyBasename()
67
+{
68
+$this->assertEquals('http://example.test/', $this->xUriDetector->detect([
69
+'REQUEST_URI' => 'http://example.test//'
70
+]));
71
+}
72
+
73
+/**
74 74
      * @throws UriException
75 75
      */
76
-    public function testUriWithParts()
77
-    {
78
-        $this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
79
-            $this->xUriDetector->detect([
80
-                'HTTP_SCHEME' => 'http',
81
-                'HTTP_HOST' => 'example.test',
82
-                'PATH_INFO' => '/path',
83
-                'QUERY_STRING' => 'param1=value1&param2="value2"',
84
-            ])
85
-        );
86
-        $this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
87
-            $this->xUriDetector->detect([
88
-                'HTTPS' => 'off',
89
-                'HTTP_HOST' => 'example.test',
90
-                'PATH_INFO' => '/path',
91
-                'QUERY_STRING' => 'param1=value1&param2="value2"',
92
-            ])
93
-        );
94
-        $this->assertEquals('https://example.test:8080/path',
95
-            $this->xUriDetector->detect([
96
-                'HTTPS' => 'on',
97
-                'SERVER_NAME' => 'example.test:8080',
98
-                'PATH_INFO' => '/path',
99
-            ])
100
-        );
101
-        $this->assertEquals('https://example.test:8080/path',
102
-            $this->xUriDetector->detect([
103
-                'HTTPS' => 'on',
104
-                'SERVER_NAME' => 'example.test',
105
-                'SERVER_PORT' => '8080',
106
-                'PATH_INFO' => '/path',
107
-            ])
108
-        );
109
-        $this->assertEquals('https://example.test:8080/path',
110
-            $this->xUriDetector->detect([
111
-                'HTTP_X_FORWARDED_SSL' => 'on',
112
-                'SERVER_NAME' => 'example.test:8080',
113
-                'PATH_INFO' => '/path',
114
-            ])
115
-        );
116
-        $this->assertEquals('https://example.test:8080/path',
117
-            $this->xUriDetector->detect([
118
-                'HTTP_X_FORWARDED_PROTO' => 'https',
119
-                'SERVER_NAME' => 'example.test:8080',
120
-                'PATH_INFO' => '/path',
121
-            ])
122
-        );
123
-    }
124
-
125
-    /**
76
+public function testUriWithParts()
77
+{
78
+$this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
79
+$this->xUriDetector->detect([
80
+    'HTTP_SCHEME' => 'http',
81
+    'HTTP_HOST' => 'example.test',
82
+    'PATH_INFO' => '/path',
83
+    'QUERY_STRING' => 'param1=value1&param2="value2"',
84
+])
85
+);
86
+$this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
87
+$this->xUriDetector->detect([
88
+    'HTTPS' => 'off',
89
+    'HTTP_HOST' => 'example.test',
90
+    'PATH_INFO' => '/path',
91
+    'QUERY_STRING' => 'param1=value1&param2="value2"',
92
+])
93
+);
94
+$this->assertEquals('https://example.test:8080/path',
95
+$this->xUriDetector->detect([
96
+    'HTTPS' => 'on',
97
+    'SERVER_NAME' => 'example.test:8080',
98
+    'PATH_INFO' => '/path',
99
+])
100
+);
101
+$this->assertEquals('https://example.test:8080/path',
102
+$this->xUriDetector->detect([
103
+    'HTTPS' => 'on',
104
+    'SERVER_NAME' => 'example.test',
105
+    'SERVER_PORT' => '8080',
106
+    'PATH_INFO' => '/path',
107
+])
108
+);
109
+$this->assertEquals('https://example.test:8080/path',
110
+$this->xUriDetector->detect([
111
+    'HTTP_X_FORWARDED_SSL' => 'on',
112
+    'SERVER_NAME' => 'example.test:8080',
113
+    'PATH_INFO' => '/path',
114
+])
115
+);
116
+$this->assertEquals('https://example.test:8080/path',
117
+$this->xUriDetector->detect([
118
+    'HTTP_X_FORWARDED_PROTO' => 'https',
119
+    'SERVER_NAME' => 'example.test:8080',
120
+    'PATH_INFO' => '/path',
121
+])
122
+);
123
+}
124
+
125
+/**
126 126
      * @throws UriException
127 127
      */
128
-    public function testRemoveJaxonParam()
129
-    {
130
-        $this->assertEquals('http://example.test/path', $this->xUriDetector->detect([
131
-            'REQUEST_URI' => 'http://example.test/path?jxnGenerate=true'
132
-        ]));
133
-        $this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
134
-            $this->xUriDetector->detect([
135
-                'REQUEST_URI' => 'http://example.test/path?param1=value1&jxnGenerate=true&param2="value2"',
136
-            ])
137
-        );
138
-    }
139
-
140
-    public function testErrorMissingHost()
141
-    {
142
-        $this->expectException(UriException::class);
143
-        $this->xUriDetector->detect([
144
-            'HTTPS' => 'on',
145
-            'PATH_INFO' => '/path',
146
-            'QUERY_STRING' => 'param1=value1&param2="value2"',
147
-        ]);
148
-    }
149
-
150
-    public function testRedirectSimpleUrl()
151
-    {
152
-        $this->assertEquals('http://example.test/path',
153
-            $this->xUriDetector->redirect('http://example.test/path', []));
154
-    }
155
-
156
-    public function testRedirectUrlWithAnchor()
157
-    {
158
-        $this->assertEquals('http://example.test/path?param=value#anchor',
159
-            $this->xUriDetector->redirect('http://example.test/path?param=value#anchor', []));
160
-    }
161
-
162
-    public function testRedirectUrlWithParam()
163
-    {
164
-        $this->assertEquals('http://example.test/path?param=value',
165
-            $this->xUriDetector->redirect('http://example.test/path?param=value', []));
166
-    }
167
-
168
-    public function testRedirectUrlWithParams()
169
-    {
170
-        $this->assertEquals('http://example.test/path?param1=value1&param2=value2',
171
-            $this->xUriDetector->redirect('http://example.test/path?param1=value1&param2=value2', []));
172
-    }
173
-
174
-    public function testRedirectUrlWithSpecialChars()
175
-    {
176
-        $this->assertEquals('http://example.test/path?param1=%22value1%22&param2=%25value2%25#anchor',
177
-            $this->xUriDetector->redirect('http://example.test/path?param1="value1"&param2=%value2%#anchor', []));
178
-    }
179
-
180
-    public function testRedirectSpecialUrl()
181
-    {
182
-        $this->assertEquals('http://example.test/?query1234',
183
-            $this->xUriDetector->redirect('http://example.test/?query1234', []));
184
-
185
-        $this->assertEquals('http://example.test/?query1234=',
186
-            $this->xUriDetector->redirect('http://example.test/?query1234=', []));
187
-
188
-        $this->assertEquals('http://example.test/?param=value&query1234=0',
189
-            $this->xUriDetector->redirect('http://example.test/?param=value&query1234=0', []));
190
-    }
191
-
192
-    public function testRedirectEncodedUrl()
193
-    {
194
-        $this->assertEquals('http://example.test/path?param1=%22value1%22&param2=%25value2%25',
195
-            $this->xUriDetector->redirect('http://example.test/path?param1=%22value1%22&param2=%25value2%25', []));
196
-    }
197
-
198
-    public function testRedirectUnexpectedUrl()
199
-    {
200
-        $this->assertEquals('http://example.test/',
201
-            $this->xUriDetector->redirect('http://example.test/? ', []));
202
-    }
203
-
204
-    public function testRedirectQueryString()
205
-    {
206
-        $this->assertEquals('http://example.test/?param1=value1',
207
-            $this->xUriDetector->redirect('http://example.test/? ', ['QUERY_STRING' => 'param1=value1']));
208
-    }
128
+public function testRemoveJaxonParam()
129
+{
130
+$this->assertEquals('http://example.test/path', $this->xUriDetector->detect([
131
+'REQUEST_URI' => 'http://example.test/path?jxnGenerate=true'
132
+]));
133
+$this->assertEquals('http://example.test/path?param1=value1&param2=%22value2%22',
134
+$this->xUriDetector->detect([
135
+    'REQUEST_URI' => 'http://example.test/path?param1=value1&jxnGenerate=true&param2="value2"',
136
+])
137
+);
138
+}
139
+
140
+public function testErrorMissingHost()
141
+{
142
+$this->expectException(UriException::class);
143
+$this->xUriDetector->detect([
144
+'HTTPS' => 'on',
145
+'PATH_INFO' => '/path',
146
+'QUERY_STRING' => 'param1=value1&param2="value2"',
147
+]);
148
+}
149
+
150
+public function testRedirectSimpleUrl()
151
+{
152
+$this->assertEquals('http://example.test/path',
153
+$this->xUriDetector->redirect('http://example.test/path', []));
154
+}
155
+
156
+public function testRedirectUrlWithAnchor()
157
+{
158
+$this->assertEquals('http://example.test/path?param=value#anchor',
159
+$this->xUriDetector->redirect('http://example.test/path?param=value#anchor', []));
160
+}
161
+
162
+public function testRedirectUrlWithParam()
163
+{
164
+$this->assertEquals('http://example.test/path?param=value',
165
+$this->xUriDetector->redirect('http://example.test/path?param=value', []));
166
+}
167
+
168
+public function testRedirectUrlWithParams()
169
+{
170
+$this->assertEquals('http://example.test/path?param1=value1&param2=value2',
171
+$this->xUriDetector->redirect('http://example.test/path?param1=value1&param2=value2', []));
172
+}
173
+
174
+public function testRedirectUrlWithSpecialChars()
175
+{
176
+$this->assertEquals('http://example.test/path?param1=%22value1%22&param2=%25value2%25#anchor',
177
+$this->xUriDetector->redirect('http://example.test/path?param1="value1"&param2=%value2%#anchor', []));
178
+}
179
+
180
+public function testRedirectSpecialUrl()
181
+{
182
+$this->assertEquals('http://example.test/?query1234',
183
+$this->xUriDetector->redirect('http://example.test/?query1234', []));
184
+
185
+$this->assertEquals('http://example.test/?query1234=',
186
+$this->xUriDetector->redirect('http://example.test/?query1234=', []));
187
+
188
+$this->assertEquals('http://example.test/?param=value&query1234=0',
189
+$this->xUriDetector->redirect('http://example.test/?param=value&query1234=0', []));
190
+}
191
+
192
+public function testRedirectEncodedUrl()
193
+{
194
+$this->assertEquals('http://example.test/path?param1=%22value1%22&param2=%25value2%25',
195
+$this->xUriDetector->redirect('http://example.test/path?param1=%22value1%22&param2=%25value2%25', []));
196
+}
197
+
198
+public function testRedirectUnexpectedUrl()
199
+{
200
+$this->assertEquals('http://example.test/',
201
+$this->xUriDetector->redirect('http://example.test/? ', []));
202
+}
203
+
204
+public function testRedirectQueryString()
205
+{
206
+$this->assertEquals('http://example.test/?param1=value1',
207
+$this->xUriDetector->redirect('http://example.test/? ', ['QUERY_STRING' => 'param1=value1']));
208
+}
209 209
 }
Please login to merge, or discard this patch.
jaxon-utils/src/Template/TemplateEngine.php 1 patch
Switch Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 
20 20
 class TemplateEngine
21 21
 {
22
-    /**
22
+/**
23 23
      * The default namespace
24 24
      *
25 25
      * @var string
26 26
      */
27
-    protected $sDefaultNamespace = '';
27
+protected $sDefaultNamespace = '';
28 28
 
29
-    /**
29
+/**
30 30
      * The namespaces
31 31
      *
32 32
      * @var array
33 33
      */
34
-    protected $aNamespaces;
34
+protected $aNamespaces;
35 35
 
36
-    /**
36
+/**
37 37
      * Set the default namespace
38 38
      *
39 39
      * @param string $sDefaultNamespace
40 40
      *
41 41
      * @return void
42 42
      */
43
-    public function setDefaultNamespace(string $sDefaultNamespace): void
44
-    {
45
-        $this->sDefaultNamespace = $sDefaultNamespace;
46
-    }
43
+public function setDefaultNamespace(string $sDefaultNamespace): void
44
+{
45
+$this->sDefaultNamespace = $sDefaultNamespace;
46
+}
47 47
 
48
-    /**
48
+/**
49 49
      * Add a namespace to the template system
50 50
      *
51 51
      * @param string $sNamespace The namespace name
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @return static
56 56
      */
57
-    public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): static
58
-    {
59
-        $this->aNamespaces[$sNamespace] = [
60
-            'directory' => rtrim(trim($sDirectory), "/\\") . DIRECTORY_SEPARATOR,
61
-            'extension' => $sExtension,
62
-        ];
63
-        return $this;
64
-    }
57
+public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): static
58
+{
59
+$this->aNamespaces[$sNamespace] = [
60
+'directory' => rtrim(trim($sDirectory), "/\\") . DIRECTORY_SEPARATOR,
61
+'extension' => $sExtension,
62
+];
63
+return $this;
64
+}
65 65
 
66
-    /**
66
+/**
67 67
      * Render a template
68 68
      *
69 69
      * @param string $sTemplate The name of template to be rendered
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return string
73 73
      */
74
-    public function render(string $sTemplate, array $aVars = []): string
75
-    {
76
-        $context = new Context($this->aNamespaces, $this->sDefaultNamespace, $sTemplate);
77
-        return $context->__render($aVars);
78
-    }
74
+public function render(string $sTemplate, array $aVars = []): string
75
+{
76
+$context = new Context($this->aNamespaces, $this->sDefaultNamespace, $sTemplate);
77
+return $context->__render($aVars);
78
+}
79 79
 }
Please login to merge, or discard this patch.
jaxon-flot/src/register.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 function register(): void
31 31
 {
32 32
     // Do nothing if running in cli.
33
-    if(php_sapi_name() !== 'cli')
33
+    if (php_sapi_name() !== 'cli')
34 34
     {
35 35
         _register();
36 36
     };
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Metadata.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
     {
140 140
         $aProperties = [];
141 141
         $aClassProperties = [];
142
-        foreach($this->aAttributes as $sType => $aValues)
142
+        foreach ($this->aAttributes as $sType => $aValues)
143 143
         {
144
-            if($sType === 'exclude')
144
+            if ($sType === 'exclude')
145 145
             {
146 146
                 continue;
147 147
             }
148 148
 
149
-            foreach($aValues as $sMethod => $xData)
149
+            foreach ($aValues as $sMethod => $xData)
150 150
             {
151
-                if($sMethod === '*')
151
+                if ($sMethod === '*')
152 152
                 {
153 153
                     $aClassProperties[$xData->getName()] = $xData->getValue();
154 154
                     continue;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             }
158 158
         }
159 159
 
160
-        if(count($aClassProperties) > 0)
160
+        if (count($aClassProperties) > 0)
161 161
         {
162 162
             $aProperties['*'] = $aClassProperties;
163 163
         }
Please login to merge, or discard this patch.
Switch Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -22,213 +22,213 @@
 block discarded – undo
22 22
 
23 23
 class Metadata
24 24
 {
25
-    /**
25
+/**
26 26
      * @var array<string, array<string, Data\AbstractData>>
27 27
      */
28
-    private array $aAttributes = [
29
-        'exclude' => [],
30
-        'export' => [],
31
-        'container' => [],
32
-        'databag' => [],
33
-        'callback' => [],
34
-        'before' => [],
35
-        'after' => [],
36
-        'upload' => [],
37
-    ];
38
-
39
-    /**
28
+private array $aAttributes = [
29
+'exclude' => [],
30
+'export' => [],
31
+'container' => [],
32
+'databag' => [],
33
+'callback' => [],
34
+'before' => [],
35
+'after' => [],
36
+'upload' => [],
37
+];
38
+
39
+/**
40 40
      * @return array<string, array<string, Data\AbstractData>>
41 41
      */
42
-    public function getAttributes(): array
43
-    {
44
-        return $this->aAttributes;
45
-    }
42
+public function getAttributes(): array
43
+{
44
+return $this->aAttributes;
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @param string $sMethod
49 49
      *
50 50
      * @return Data\ExcludeData
51 51
      */
52
-    public function exclude(string $sMethod = '*'): Data\ExcludeData
53
-    {
54
-        return $this->aAttributes['exclude'][$sMethod] ??
55
-            $this->aAttributes['exclude'][$sMethod] = new Data\ExcludeData();
56
-    }
52
+public function exclude(string $sMethod = '*'): Data\ExcludeData
53
+{
54
+return $this->aAttributes['exclude'][$sMethod] ??
55
+$this->aAttributes['exclude'][$sMethod] = new Data\ExcludeData();
56
+}
57 57
 
58
-    /**
58
+/**
59 59
      * @param string $sMethod
60 60
      *
61 61
      * @return Data\ExportData
62 62
      */
63
-    public function export(string $sMethod = '*'): Data\ExportData
64
-    {
65
-        $sMethod = '*'; // On classes only
66
-        return $this->aAttributes['export'][$sMethod] ??
67
-            $this->aAttributes['export'][$sMethod] = new Data\ExportData();
68
-    }
63
+public function export(string $sMethod = '*'): Data\ExportData
64
+{
65
+$sMethod = '*'; // On classes only
66
+return $this->aAttributes['export'][$sMethod] ??
67
+$this->aAttributes['export'][$sMethod] = new Data\ExportData();
68
+}
69 69
 
70
-    /**
70
+/**
71 71
      * @param string $sMethod
72 72
      *
73 73
      * @return Data\ContainerData
74 74
      */
75
-    public function container(string $sMethod = '*'): Data\ContainerData
76
-    {
77
-        return $this->aAttributes['container'][$sMethod] ??
78
-            $this->aAttributes['container'][$sMethod] = new Data\ContainerData();
79
-    }
75
+public function container(string $sMethod = '*'): Data\ContainerData
76
+{
77
+return $this->aAttributes['container'][$sMethod] ??
78
+$this->aAttributes['container'][$sMethod] = new Data\ContainerData();
79
+}
80 80
 
81
-    /**
81
+/**
82 82
      * @param string $sMethod
83 83
      *
84 84
      * @return Data\DatabagData
85 85
      */
86
-    public function databag(string $sMethod = '*'): Data\DatabagData
87
-    {
88
-        return $this->aAttributes['databag'][$sMethod] ??
89
-            $this->aAttributes['databag'][$sMethod] = new Data\DatabagData();
90
-    }
86
+public function databag(string $sMethod = '*'): Data\DatabagData
87
+{
88
+return $this->aAttributes['databag'][$sMethod] ??
89
+$this->aAttributes['databag'][$sMethod] = new Data\DatabagData();
90
+}
91 91
 
92
-    /**
92
+/**
93 93
      * @param string $sMethod
94 94
      *
95 95
      * @return Data\CallbackData
96 96
      */
97
-    public function callback(string $sMethod = '*'): Data\CallbackData
98
-    {
99
-        return $this->aAttributes['callback'][$sMethod] ??
100
-            $this->aAttributes['callback'][$sMethod] = new Data\CallbackData();
101
-    }
97
+public function callback(string $sMethod = '*'): Data\CallbackData
98
+{
99
+return $this->aAttributes['callback'][$sMethod] ??
100
+$this->aAttributes['callback'][$sMethod] = new Data\CallbackData();
101
+}
102 102
 
103
-    /**
103
+/**
104 104
      * @param string $sMethod
105 105
      *
106 106
      * @return Data\BeforeData
107 107
      */
108
-    public function before(string $sMethod = '*'): Data\BeforeData
109
-    {
110
-        return $this->aAttributes['before'][$sMethod] ??
111
-            $this->aAttributes['before'][$sMethod] = new Data\BeforeData();
112
-    }
108
+public function before(string $sMethod = '*'): Data\BeforeData
109
+{
110
+return $this->aAttributes['before'][$sMethod] ??
111
+$this->aAttributes['before'][$sMethod] = new Data\BeforeData();
112
+}
113 113
 
114
-    /**
114
+/**
115 115
      * @param string $sMethod
116 116
      *
117 117
      * @return Data\AfterData
118 118
      */
119
-    public function after(string $sMethod = '*'): Data\AfterData
120
-    {
121
-        return $this->aAttributes['after'][$sMethod] ??
122
-            $this->aAttributes['after'][$sMethod] = new Data\AfterData();
123
-    }
119
+public function after(string $sMethod = '*'): Data\AfterData
120
+{
121
+return $this->aAttributes['after'][$sMethod] ??
122
+$this->aAttributes['after'][$sMethod] = new Data\AfterData();
123
+}
124 124
 
125
-    /**
125
+/**
126 126
      * @param string $sMethod
127 127
      *
128 128
      * @return Data\UploadData
129 129
      */
130
-    public function upload(string $sMethod = '*'): Data\UploadData
131
-    {
132
-        return $this->aAttributes['upload'][$sMethod] ??
133
-            $this->aAttributes['upload'][$sMethod] = new Data\UploadData();
134
-    }
130
+public function upload(string $sMethod = '*'): Data\UploadData
131
+{
132
+return $this->aAttributes['upload'][$sMethod] ??
133
+$this->aAttributes['upload'][$sMethod] = new Data\UploadData();
134
+}
135 135
 
136
-    /**
136
+/**
137 137
      * True if the class is excluded
138 138
      *
139 139
      * @return bool
140 140
      */
141
-    public function isExcluded(): bool
142
-    {
143
-        $xData = $this->aAttributes['exclude']['*'] ?? null;
144
-        return $xData !== null && $xData->getValue() === true;
145
-    }
141
+public function isExcluded(): bool
142
+{
143
+$xData = $this->aAttributes['exclude']['*'] ?? null;
144
+return $xData !== null && $xData->getValue() === true;
145
+}
146 146
 
147
-    /**
147
+/**
148 148
      * Get the properties of the class methods
149 149
      *
150 150
      * @return array
151 151
      */
152
-    public function getProperties(): array
152
+public function getProperties(): array
153
+{
154
+$aProperties = [];
155
+$aClassProperties = [];
156
+foreach($this->aAttributes as $sType => $aValues)
157
+{
158
+if($sType === 'exclude')
159
+{
160
+    continue;
161
+}
162
+
163
+foreach($aValues as $sMethod => $xData)
164
+{
165
+    if($sMethod === '*')
153 166
     {
154
-        $aProperties = [];
155
-        $aClassProperties = [];
156
-        foreach($this->aAttributes as $sType => $aValues)
157
-        {
158
-            if($sType === 'exclude')
159
-            {
160
-                continue;
161
-            }
162
-
163
-            foreach($aValues as $sMethod => $xData)
164
-            {
165
-                if($sMethod === '*')
166
-                {
167
-                    $aClassProperties[$xData->getName()] = $xData->getValue();
168
-                    continue;
169
-                }
170
-                $aProperties[$sMethod][$xData->getName()] = $xData->getValue();
171
-            }
172
-        }
173
-
174
-        if(count($aClassProperties) > 0)
175
-        {
176
-            $aProperties['*'] = $aClassProperties;
177
-        }
178
-
179
-        return $aProperties;
167
+        $aClassProperties[$xData->getName()] = $xData->getValue();
168
+        continue;
180 169
     }
170
+    $aProperties[$sMethod][$xData->getName()] = $xData->getValue();
171
+}
172
+}
181 173
 
182
-    /**
174
+if(count($aClassProperties) > 0)
175
+{
176
+$aProperties['*'] = $aClassProperties;
177
+}
178
+
179
+return $aProperties;
180
+}
181
+
182
+/**
183 183
      * Get the methods in the export attributes
184 184
      *
185 185
      * @return array
186 186
      */
187
-    public function getExportMethods(): array
188
-    {
189
-        /** @var array<Data\ExcludeData> */
190
-        $aAttributes = $this->aAttributes['exclude'];
191
-        $aExcludeMethods = array_keys($aAttributes);
192
-        $aExcludeMethods = array_values(array_filter($aExcludeMethods,
193
-            fn(string $sName) => $sName !== '*' &&
194
-                $aAttributes[$sName]->getValue() === true));
195
-
196
-        /** @var Data\ExportData|null */
197
-        $xExportData = $this->aAttributes['export']['*'] ?? null;
198
-        $aExportMethods = $xExportData?->getValue() ?? [];
199
-
200
-        $aExceptMethods = $aExportMethods['except'] ?? [];
201
-        $aExportMethods['except'] = array_merge($aExcludeMethods, $aExceptMethods);
202
-        return $aExportMethods;
203
-    }
187
+public function getExportMethods(): array
188
+{
189
+/** @var array<Data\ExcludeData> */
190
+$aAttributes = $this->aAttributes['exclude'];
191
+$aExcludeMethods = array_keys($aAttributes);
192
+$aExcludeMethods = array_values(array_filter($aExcludeMethods,
193
+fn(string $sName) => $sName !== '*' &&
194
+    $aAttributes[$sName]->getValue() === true));
195
+
196
+/** @var Data\ExportData|null */
197
+$xExportData = $this->aAttributes['export']['*'] ?? null;
198
+$aExportMethods = $xExportData?->getValue() ?? [];
199
+
200
+$aExceptMethods = $aExportMethods['except'] ?? [];
201
+$aExportMethods['except'] = array_merge($aExcludeMethods, $aExceptMethods);
202
+return $aExportMethods;
203
+}
204 204
 
205
-    /**
205
+/**
206 206
      * Get the exluded methods
207 207
      *
208 208
      * @return array
209 209
      */
210
-    public function getExceptMethods(): array
211
-    {
212
-        return $this->getExportMethods()['except'];
213
-    }
210
+public function getExceptMethods(): array
211
+{
212
+return $this->getExportMethods()['except'];
213
+}
214 214
 
215
-    /**
215
+/**
216 216
      * Get the export base methods
217 217
      *
218 218
      * @return array
219 219
      */
220
-    public function getExportBaseMethods(): array
221
-    {
222
-        return $this->getExportMethods()['base'] ?? [];
223
-    }
220
+public function getExportBaseMethods(): array
221
+{
222
+return $this->getExportMethods()['base'] ?? [];
223
+}
224 224
 
225
-    /**
225
+/**
226 226
      * Get the export only methods
227 227
      *
228 228
      * @return array
229 229
      */
230
-    public function getExportOnlyMethods(): array
231
-    {
232
-        return $this->getExportMethods()['only'] ?? [];
233
-    }
230
+public function getExportOnlyMethods(): array
231
+{
232
+return $this->getExportMethods()['only'] ?? [];
233
+}
234 234
 }
Please login to merge, or discard this patch.
jaxon-core/src/Script/CallFactory.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@
 block discarded – undo
50 50
     public function rq(string $sClassName = ''): ?JxnCall
51 51
     {
52 52
         $sClassName = trim($sClassName);
53
-        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() :
54
-            $this->cdi->getComponentRequestFactory($sClassName);
53
+        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() : $this->cdi->getComponentRequestFactory($sClassName);
55 54
     }
56 55
 
57 56
     /**
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/MetadataCache.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@
 block discarded – undo
51 51
         $sMetadataVar = '$xMetadata';
52 52
         $sDataVar = '$xData';
53 53
         $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
54
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
54
+        foreach ($xMetadata->getAttributes() as $sType => $aValues)
55 55
         {
56
-            foreach($aValues as $sMethod => $xData)
56
+            foreach ($aValues as $sMethod => $xData)
57 57
             {
58 58
                 $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
59
-                foreach($xData->encode($sDataVar) as $sCall)
59
+                foreach ($xData->encode($sDataVar) as $sCall)
60 60
                 {
61 61
                     $aCalls[] = $sCall;
62 62
                 }
Please login to merge, or discard this patch.
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,60 +28,60 @@  discard block
 block discarded – undo
28 28
 
29 29
 class MetadataCache
30 30
 {
31
-    /**
31
+/**
32 32
      * @param string $sCacheDir
33 33
      */
34
-    public function __construct(private string $sCacheDir)
35
-    {}
34
+public function __construct(private string $sCacheDir)
35
+{}
36 36
 
37
-    /**
37
+/**
38 38
      * @param string $sClass
39 39
      *
40 40
      * @return string
41 41
      */
42
-    private function filepath(string $sClass): string
43
-    {
44
-        $sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
-            strtolower($sClass)), DIRECTORY_SEPARATOR);
46
-        return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
-            "metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
-    }
42
+private function filepath(string $sClass): string
43
+{
44
+$sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
+strtolower($sClass)), DIRECTORY_SEPARATOR);
46
+return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
+"metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
+}
49 49
 
50
-    /**
50
+/**
51 51
      * Generate the PHP code to create a metadata object.
52 52
      *
53 53
      * @return array
54 54
      */
55
-    private function encode(Metadata $xMetadata): array
55
+private function encode(Metadata $xMetadata): array
56
+{
57
+$sMetadataVar = '$xMetadata';
58
+$sDataVar = '$xData';
59
+$aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
+foreach($xMetadata->getAttributes() as $sType => $aValues)
61
+{
62
+foreach($aValues as $sMethod => $xData)
63
+{
64
+    $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
+    foreach($xData->encode($sDataVar) as $sCall)
56 66
     {
57
-        $sMetadataVar = '$xMetadata';
58
-        $sDataVar = '$xData';
59
-        $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
61
-        {
62
-            foreach($aValues as $sMethod => $xData)
63
-            {
64
-                $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
-                foreach($xData->encode($sDataVar) as $sCall)
66
-                {
67
-                    $aCalls[] = $sCall;
68
-                }
69
-            }
70
-        }
71
-        $aCalls[] = "return $sMetadataVar;";
72
-        return $aCalls;
67
+        $aCalls[] = $sCall;
73 68
     }
69
+}
70
+}
71
+$aCalls[] = "return $sMetadataVar;";
72
+return $aCalls;
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @param string $sClass
77 77
      * @param Metadata $xMetadata
78 78
      *
79 79
      * @return void
80 80
      */
81
-    public function save(string $sClass, Metadata $xMetadata): void
82
-    {
83
-        $sDataCode = implode("\n    ", $this->encode($xMetadata));
84
-        $sPhpCode = <<<CODE
81
+public function save(string $sClass, Metadata $xMetadata): void
82
+{
83
+$sDataCode = implode("\n    ", $this->encode($xMetadata));
84
+$sPhpCode = <<<CODE
85 85
 <?php
86 86
 
87 87
 return function() {
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 };
90 90
 
91 91
 CODE;
92
-        // Recursively create the directories.
93
-        $sPath = $this->filepath($sClass);
94
-        @mkdir(dirname($sPath), 0755, true);
95
-        file_put_contents($sPath, $sPhpCode);
96
-    }
92
+// Recursively create the directories.
93
+$sPath = $this->filepath($sClass);
94
+@mkdir(dirname($sPath), 0755, true);
95
+file_put_contents($sPath, $sPhpCode);
96
+}
97 97
 
98
-    /**
98
+/**
99 99
      * @param string $sClass
100 100
      *
101 101
      * @return Metadata|null
102 102
      */
103
-    public function read(string $sClass): ?Metadata
104
-    {
105
-        $sPath = $this->filepath($sClass);
106
-        $fCreator = file_exists($sPath) ? require $sPath : null;
107
-        return $fCreator instanceof Closure ? $fCreator() : null;
108
-    }
103
+public function read(string $sClass): ?Metadata
104
+{
105
+$sPath = $this->filepath($sClass);
106
+$fCreator = file_exists($sPath) ? require $sPath : null;
107
+return $fCreator instanceof Closure ? $fCreator() : null;
108
+}
109 109
 }
Please login to merge, or discard this patch.