@@ -78,7 +78,7 @@ |
||
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 |
@@ -201,13 +201,14 @@ |
||
201 | 201 | $input = new Element($tag, $content, $attributes); |
202 | 202 | |
203 | 203 | if($label_text){ |
204 | - if (!empty($attributes['label-wrap'])) |
|
205 | - $ret = self::label(null, $label_text.$input); |
|
206 | - else |
|
207 | - $ret = self::label($attributes['id'], $label_text).$input; |
|
204 | + if (!empty($attributes['label-wrap'])) { |
|
205 | + $ret = self::label(null, $label_text.$input); |
|
206 | + } else { |
|
207 | + $ret = self::label($attributes['id'], $label_text).$input; |
|
208 | + } |
|
209 | + } else { |
|
210 | + $ret = $input; |
|
208 | 211 | } |
209 | - else |
|
210 | - $ret = $input; |
|
211 | 212 | |
212 | 213 | return (string)$ret; |
213 | 214 | } |
@@ -1,9 +1,9 @@ discard block |
||
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 |
||
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): Element |
21 | 21 | { |
22 | 22 | $attributes['src'] ??= $src; |
@@ -27,11 +27,11 @@ discard block |
||
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): Element |
36 | 36 | { |
37 | 37 | $attributes['href'] = $href; |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 | } |