@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $this->tag = $tag; |
| 38 | 38 | $this->inner = $inner; |
| 39 | - foreach($attributes as $name => $value) |
|
| 39 | + foreach ($attributes as $name => $value) |
|
| 40 | 40 | { |
| 41 | 41 | // is boolean attribute ? |
| 42 | - if(is_int($name)) |
|
| 42 | + if (is_int($name)) |
|
| 43 | 43 | { |
| 44 | 44 | $this->$value = true; |
| 45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $this->formatter = $formatter ?? function($value){ |
|
| 52 | + $this->formatter = $formatter ?? function($value) { |
|
| 53 | 53 | return htmlspecialchars($value, ENT_QUOTES); |
| 54 | 54 | }; |
| 55 | 55 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | foreach ($this->attributes as $name => $value) { |
| 84 | 84 | $name = call_user_func($this->formatter, $name); |
| 85 | - $attributes .= ' ' . ($value === true ? $name : sprintf('%s="%s"', $name, call_user_func($this->formatter, (string)$value))); |
|
| 85 | + $attributes .= ' '.($value === true ? $name : sprintf('%s="%s"', $name, call_user_func($this->formatter, (string)$value))); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return $this->inner === null |
@@ -107,7 +107,7 @@ discard block |
||
| 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', "$label", $option_attributes); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public static function legend(string $label, array $attributes = []): string |
| 127 | 127 | { |
| 128 | - return '' . (new Element('legend', $label, $attributes)); |
|
| 128 | + return ''.(new Element('legend', $label, $attributes)); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | public static function button(string $label, array $attributes = []): string |
| 148 | 148 | { |
| 149 | - return '' . (new Element('button', $label, $attributes)); |
|
| 149 | + return ''.(new Element('button', $label, $attributes)); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | = |
| 202 | 202 | $input = new Element($tag, $content, $attributes); |
| 203 | 203 | |
| 204 | - if($label_text){ |
|
| 204 | + if ($label_text) { |
|
| 205 | 205 | if (!empty($attributes['label-wrap'])) |
| 206 | 206 | $ret = self::label(null, $label_text.$input); |
| 207 | 207 | else |
@@ -65,7 +65,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |