Passed
Push — main ( 1e7c3f...356a9e )
by Sammy
07:23
created
src/WCAGElement.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param array  $attributes Additional attributes
66 66
      * @return string
67 67
      */
68
-    public static function img(string $src, string $alt='', $attributes = [])
68
+    public static function img(string $src, string $alt = '', $attributes = [])
69 69
     {
70 70
         $attributes['src'] = $src;
71 71
         $attributes['alt'] = $alt;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
         $content .= parent::figcaption($caption);
90 90
         $attributes['role'] = 'figure';
91
-        return parent::figure($content, $attributes, function ($value) {
91
+        return parent::figure($content, $attributes, function($value) {
92 92
             return $value;
93 93
         });
94 94
     }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public static function audio(string $src, $attributes = [])
120 120
     {
121
-        if(empty($src)) {
121
+        if (empty($src)) {
122 122
             throw new \InvalidArgumentException("Source attribute is required");
123 123
         }
124 124
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public static function iframe(string $src, string $title, $attributes = [])
152 152
     {
153
-        if(empty($title)) {
153
+        if (empty($title)) {
154 154
             throw new \InvalidArgumentException("Iframe title is required");
155 155
         }
156 156
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public static function a(string $href, string $content, $attributes = [])
168 168
     {
169
-        if(empty($href)) {
169
+        if (empty($href)) {
170 170
             throw new \InvalidArgumentException("Anchor href is required");
171 171
         }
172 172
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      */
182 182
     public static function area(string $alt, $attributes = [])
183 183
     {
184
-        if(empty($alt)) {
184
+        if (empty($alt)) {
185 185
             throw new \InvalidArgumentException("Area alt is required");
186 186
         }
187 187
         $attributes['alt'] = $alt;
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public static function input(string $type, string $name, $attributes = [])
197 197
     {
198
-        if(empty($type)) {
198
+        if (empty($type)) {
199 199
             throw new \InvalidArgumentException("Input type is required");
200 200
         }
201 201
 
202
-        if(empty($name)) {
202
+        if (empty($name)) {
203 203
             throw new \InvalidArgumentException("Input name is required");
204 204
         }
205 205
 
206 206
         $attributes['name'] = $name;
207 207
         $attributes['type'] = $type;
208 208
 
209
-        if(self::inputIsRequired($attributes)) {
209
+        if (self::inputIsRequired($attributes)) {
210 210
             $attributes['aria-required'] = 'true';
211 211
         }
212 212
 
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
         }
231 231
         $attributes['name'] = $name;
232 232
         $string_options = '';
233
-        foreach($options as $value => $label) {
234
-            $string_options.= parent::option($label, ['value' => $value]);
233
+        foreach ($options as $value => $label) {
234
+            $string_options .= parent::option($label, ['value' => $value]);
235 235
         }
236
-        return parent::select($string_options, $attributes, function ($value) {
236
+        return parent::select($string_options, $attributes, function($value) {
237 237
             return $value;
238 238
         });
239 239
     }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public static function html(string $content, $attributes = [])
273 273
     {
274
-        if(empty($content)) {
274
+        if (empty($content)) {
275 275
             throw new \InvalidArgumentException("HTML content is required");
276 276
         }
277 277
 
278
-        if(empty($attributes['lang'])) {
278
+        if (empty($attributes['lang'])) {
279 279
             throw new \InvalidArgumentException("Language attribute is required");
280 280
         }
281 281
         return parent::html($content, $attributes);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public static function th(string $scope, string $content, $attributes = [])
290 290
     {
291
-        if(empty($scope)) {
291
+        if (empty($scope)) {
292 292
             throw new \InvalidArgumentException("Scope attribute is required");
293 293
         }
294 294
 
Please login to merge, or discard this patch.
src/Element.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 
79 79
         foreach ($this->attributes as $name => $value) {
80 80
             $name = ($this->formatter)($name);
81
-            $attributes .= ' ' . ($value === true ? $name : sprintf('%s="%s"', $name, ($this->formatter)((string)$value)));
81
+            $attributes .= ' '.($value === true ? $name : sprintf('%s="%s"', $name, ($this->formatter)((string)$value)));
82 82
         }
83 83
 
84 84
         return $this->inner === null
Please login to merge, or discard this patch.
tests/ElementTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $element = new Element('div', $content, ['class' => ['foo', 'bar'], 'id' => 'test'], false);
141 141
 
142 142
         $this->assertEquals(
143
-            '<div class="foo bar" id="test">' . $content . '</div>',
143
+            '<div class="foo bar" id="test">'.$content.'</div>',
144 144
             $element->__toString()
145 145
         );
146 146
         $content = 'Hello, World! & < > " \' ';
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         ], 'id' => 'test', 'data-attr' => $content], false);
151 151
 
152 152
         $this->assertEquals(
153
-            '<div class="foo bar" id="test" data-attr="' . $content . '">' . $content . '</div>',
153
+            '<div class="foo bar" id="test" data-attr="'.$content.'">'.$content.'</div>',
154 154
             $element->__toString()
155 155
         );
156 156
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
         $element = new Element('div', $content, ['class' => ['foo', 'bar'], 'id' => 'test', 'data-attr' => $content, 'data-attr2' => $content], false);
160 160
 
161 161
         $this->assertEquals(
162
-            '<div class="foo bar" id="test" data-attr="' . $content . '" data-attr2="' . $content .
163
-                '">' . $content . '</div>',
162
+            '<div class="foo bar" id="test" data-attr="'.$content.'" data-attr2="'.$content.
163
+                '">'.$content.'</div>',
164 164
             $element->__toString()
165 165
         );
166 166
     }
Please login to merge, or discard this patch.
src/Marker.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /**
4
-  * HTML generator
5
-  * Marker, hommage to Christian François Bouche-Villeneuve aka Chris Marker
6
-  */
4
+ * HTML generator
5
+ * Marker, hommage to Christian François Bouche-Villeneuve aka Chris Marker
6
+ */
7 7
 
8 8
 declare(strict_types=1);
9 9
 
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 class Marker extends Element
13 13
 {
14 14
     /**
15
-      * ? smoother write
16
-      * Marker::img('path/to/img.jpg', 'An alternative text', ['width' => 34, 'height' => 34])
17
-      * than
18
-      * Element::img(null, ['src' => 'path/to/img.jpg', 'alt' => 'An alternative text', 'width' => 34, 'height' => 34])
19
-      */
15
+     * ? smoother write
16
+     * Marker::img('path/to/img.jpg', 'An alternative text', ['width' => 34, 'height' => 34])
17
+     * than
18
+     * Element::img(null, ['src' => 'path/to/img.jpg', 'alt' => 'An alternative text', 'width' => 34, 'height' => 34])
19
+     */
20 20
     public static function img(string $src, string $alt, array $attributes = [], $formatter=null): Element
21 21
     {
22 22
         $attributes['src'] ??= $src;
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
     }
28 28
 
29 29
     /**
30
-      * ? makes more sense to write
31
-      * Marker::a('controller/task/id', 'Click here', ['class' => 'nav'])
32
-      * than
33
-      * Marker::a('Click here', ['href' => controller/task/id', 'class' => 'nav'])
34
-      */
30
+     * ? makes more sense to write
31
+     * Marker::a('controller/task/id', 'Click here', ['class' => 'nav'])
32
+     * than
33
+     * Marker::a('Click here', ['href' => controller/task/id', 'class' => 'nav'])
34
+     */
35 35
     public static function a(string $href, string $label, array $attributes = [], $formatter = null): Element
36 36
     {
37 37
         $attributes['href'] = $href;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
       * than
18 18
       * Element::img(null, ['src' => 'path/to/img.jpg', 'alt' => 'An alternative text', 'width' => 34, 'height' => 34])
19 19
       */
20
-    public static function img(string $src, string $alt, array $attributes = [], $formatter=null): Element
20
+    public static function img(string $src, string $alt, array $attributes = [], $formatter = null): Element
21 21
     {
22 22
         $attributes['src'] ??= $src;
23 23
         $attributes['alt'] ??= $alt;
24 24
         $attributes['title'] ??= $alt;
25 25
 
26
-        return new Element('img', null,$attributes, $formatter);
26
+        return new Element('img', null, $attributes, $formatter);
27 27
     }
28 28
 
29 29
     /**
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
     {
37 37
         $attributes['href'] = $href;
38 38
 
39
-        return new Element('a', $label,$attributes, $formatter);
39
+        return new Element('a', $label, $attributes, $formatter);
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
src/Form.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         foreach ($list as $value => $label) {
108 108
             $option_attributes = ['value' => $value];
109 109
             if ($selected == $value) {
110
-                $option_attributes['selected'] =  'selected';
110
+                $option_attributes['selected'] = 'selected';
111 111
             }
112 112
 
113 113
             $options .= new Element('option', (string)$label, $option_attributes);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function legend(string $label, array $attributes = []): string
126 126
     {
127
-        return '' . (new Element('legend', $label, $attributes));
127
+        return ''.(new Element('legend', $label, $attributes));
128 128
     }
129 129
 
130 130
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     public static function button(string $label, array $attributes = []): string
147 147
     {
148
-        return  '' . (new Element('button', $label, $attributes));
148
+        return  ''.(new Element('button', $label, $attributes));
149 149
     }
150 150
 
151 151
     /**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         unset($attributes['label']);
200 200
         $input = new Element($tag, $content, $attributes, false);
201 201
 
202
-        if($label_text){
202
+        if ($label_text) {
203 203
             if (!empty($attributes['label-wrap']))
204 204
                 $ret = self::label(null, $label_text.$input);
205 205
             else
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -200,13 +200,14 @@
 block discarded – undo
200 200
         $input = new Element($tag, $content, $attributes, false);
201 201
 
202 202
         if($label_text){
203
-            if (!empty($attributes['label-wrap']))
204
-                $ret = self::label(null, $label_text.$input);
205
-            else
206
-                $ret = self::label($attributes['id'], $label_text).$input;
203
+            if (!empty($attributes['label-wrap'])) {
204
+                            $ret = self::label(null, $label_text.$input);
205
+            } else {
206
+                            $ret = self::label($attributes['id'], $label_text).$input;
207
+            }
208
+        } else {
209
+                    $ret = $input;
207 210
         }
208
-        else
209
-            $ret = $input;
210 211
 
211 212
         return (string)$ret;
212 213
     }
Please login to merge, or discard this patch.