1 | <?php |
||
11 | class Tag extends AbstractBaseHtmlTagObject implements TagInterface |
||
12 | { |
||
13 | /** |
||
14 | * The tag name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | private $tag; |
||
19 | |||
20 | /** |
||
21 | * The tag attributes. |
||
22 | * |
||
23 | * @var \drupol\htmltag\Attributes\AttributesInterface |
||
24 | */ |
||
25 | private $attributes; |
||
26 | |||
27 | /** |
||
28 | * The tag content. |
||
29 | * |
||
30 | * @var mixed[]|null |
||
31 | */ |
||
32 | private $content; |
||
33 | |||
34 | /** |
||
35 | * Tag constructor. |
||
36 | * |
||
37 | * @param \drupol\htmltag\Attributes\AttributesInterface $attributes |
||
38 | * @param string $name |
||
39 | * The tag name. |
||
40 | * @param mixed $content |
||
41 | * The content. |
||
42 | */ |
||
43 | 9 | public function __construct(AttributesInterface $attributes, $name, $content = false) |
|
49 | |||
50 | /** |
||
51 | * @param string $name |
||
52 | * @param array $arguments |
||
53 | * |
||
54 | * @return \drupol\htmltag\Tag\TagInterface |
||
55 | */ |
||
56 | 1 | public static function __callStatic($name, array $arguments = []) |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 1 | public function __toString() |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 3 | public function attr($name = null, ...$value) |
|
73 | { |
||
74 | 3 | if (null === $name) { |
|
75 | 1 | return $this->attributes->render(); |
|
76 | } |
||
77 | |||
78 | 3 | if ([] === $value) { |
|
79 | 2 | return $this->attributes[$name]; |
|
80 | } |
||
81 | |||
82 | 1 | return $this->attributes[$name]->set($value); |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 9 | public function content(...$content) |
|
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | 7 | public function render() |
|
114 | |||
115 | /** |
||
116 | * Render the tag content. |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 9 | private function renderContent() |
|
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | 9 | protected function preprocess(array $values, $name = null) |
|
163 | |||
164 | /** |
||
165 | * {@inheritdoc} |
||
166 | */ |
||
167 | 1 | public function serialize() |
|
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | 1 | public function unserialize($serialized) |
|
187 | } |
||
188 |