generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHasTag.php
36 lines (30 loc) · 846 Bytes
/
HasTag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Concern;
/**
* Is used by widgets that implement the tag method.
*/
trait HasTag
{
protected false|string $tag = false;
/**
* Set the tag of the element.
*
* @param false|string $value The tag name for the element.
* If `false` the tag will be disabled.
*
* @throws \InvalidArgumentException If the container tag is an empty string.
*
* @return static A new instance of the current class with the specified tag.
* If `false` the tag will be disabled.
*/
public function tag(false|string $value): static
{
if ($value === '') {
throw new \InvalidArgumentException('The tag cannot be an empty string.');
}
$new = clone $this;
$new->tag = $value;
return $new;
}
}