Skip to content

Commit 3738070

Browse files
committed
Remove dependency
1 parent 185e539 commit 3738070

File tree

3 files changed

+379
-43
lines changed

3 files changed

+379
-43
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"require": {
1111
"php": "^8.0",
1212
"laravel/framework": "^9.21|^10.0",
13-
"airmanbzh/php-html-generator": "dev-master"
1413
},
1514
"require-dev": {
1615
"orchestra/testbench": "^7.0|^8.0",

src/Html.php

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,45 @@
1313
*/
1414
class Html extends Markup
1515
{
16-
/**
17-
* Auto close these tags.
18-
*
19-
* @var array<int, string>
20-
*/
21-
protected $autocloseTagsList = [
22-
'img', 'br', 'hr', 'input', 'area', 'link', 'meta', 'param',
23-
];
24-
2516
/**
2617
* Current tag.
2718
*
2819
* @var string
2920
*/
3021
protected $tag = 'tag';
3122

23+
/**
24+
* @param string $tag
25+
* @param array<mixed> $arguments
26+
*/
27+
public function __call($tag, $arguments): Html
28+
{
29+
// Reserved word: `call` ->class()
30+
if ($tag === 'class') {
31+
return $this->addClass(...$arguments);
32+
}
33+
34+
// Reserved word: `for` ->for()
35+
if ($tag === 'for') {
36+
return $this->addFor(...$arguments);
37+
}
38+
39+
array_unshift($arguments, $tag);
40+
41+
return call_user_func_array([$this, 'addElement'], $arguments);
42+
}
43+
44+
/**
45+
* @param string $tag
46+
* @param array<mixed> $arguments
47+
*/
48+
public static function __callStatic($tag, $arguments): Html
49+
{
50+
array_unshift($arguments, $tag);
51+
52+
return call_user_func_array(['self', 'createElement'], $arguments);
53+
}
54+
3255
/**
3356
* Shortcut to set('action', $url).
3457
*/
@@ -1013,7 +1036,7 @@ public function s(\Closure|string|bool|null $value = true): string
10131036
/**
10141037
* (Re)Define an attribute.
10151038
*
1016-
* @param ?string $name
1039+
* @param string|array<mixed>|null $name
10171040
* @param ?string $value
10181041
*/
10191042
public function set($name, $value = null): Html
@@ -1360,36 +1383,4 @@ public static function tr(mixed ...$arguments): Html
13601383

13611384
return self::createElement(...$arguments);
13621385
}
1363-
1364-
/**
1365-
* @param string $tag
1366-
* @param array<mixed> $arguments
1367-
*/
1368-
public function __call($tag, $arguments): Html
1369-
{
1370-
// Reserved word: `call` ->class()
1371-
if ($tag === 'class') {
1372-
return $this->addClass(...$arguments);
1373-
}
1374-
1375-
// Reserved word: `for` ->for()
1376-
if ($tag === 'for') {
1377-
return $this->addFor(...$arguments);
1378-
}
1379-
1380-
array_unshift($arguments, $tag);
1381-
1382-
return call_user_func_array([$this, 'addElement'], $arguments);
1383-
}
1384-
1385-
/**
1386-
* @param string $tag
1387-
* @param array<mixed> $arguments
1388-
*/
1389-
public static function __callStatic($tag, $arguments): Html
1390-
{
1391-
array_unshift($arguments, $tag);
1392-
1393-
return call_user_func_array(['self', 'createElement'], $arguments);
1394-
}
13951386
}

0 commit comments

Comments
 (0)