1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebTheory\Html; |
4
|
|
|
|
5
|
|
|
use WebTheory\Html\Traits\ElementConstructorTrait; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @method static string div(string $inner = '', array attributes = []) |
9
|
|
|
* @method static string span(string $inner = '', array attributes = []) |
10
|
|
|
* @method static string main(string $inner = '', array attributes = []) |
11
|
|
|
* @method static string form(string $inner = '', array attributes = []) |
12
|
|
|
* @method static string h1(string $inner = '', array attributes = []) |
13
|
|
|
* @method static string h2(string $inner = '', array attributes = []) |
14
|
|
|
* @method static string h3(string $inner = '', array attributes = []) |
15
|
|
|
* @method static string h4(string $inner = '', array attributes = []) |
16
|
|
|
* @method static string h5(string $inner = '', array attributes = []) |
17
|
|
|
* @method static string h6(string $inner = '', array attributes = []) |
18
|
|
|
* @method static string input(array attributes = []) |
19
|
|
|
*/ |
20
|
|
|
class Html |
21
|
|
|
{ |
22
|
|
|
use ElementConstructorTrait { |
23
|
|
|
tag as public; |
24
|
|
|
open as public; |
25
|
|
|
close as public; |
26
|
|
|
maybeClose as public; |
27
|
|
|
tagIsVoid as public; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
*/ |
33
|
|
|
public static function attributes(array $attributes, bool $trim = true) |
34
|
|
|
{ |
35
|
|
|
$attributes = static::parseAttributes($attributes); |
36
|
|
|
|
37
|
|
|
return $trim ? ltrim($attributes) : $attributes; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* |
42
|
|
|
*/ |
43
|
|
|
public static function __callStatic($tag, $args) |
44
|
|
|
{ |
45
|
|
|
if (static::tagIsVoid($tag)) { |
46
|
|
|
return static::tag($tag, $args[0] ?? []); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return static::tag($tag, $args[1] ?? [], $args[0] ?? ''); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|