generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHasValue.php
40 lines (35 loc) · 971 Bytes
/
HasValue.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
37
38
39
40
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute;
/**
* Is used by widgets that implement the value method.
*/
trait HasValue
{
/**
* Get the value content attribute gives the default value of the field.
*
* @return mixed The value of the widget.
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-value
*/
public function getValue(): mixed
{
return $this->attributes['value'] ?? null;
}
/**
* set the value content attribute gives the default value of the field.
*
* @param mixed $value The value of the widget.
*
* @return static A new instance of the current class with the specified value.
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-value
*/
public function value(mixed $value): static
{
$new = clone $this;
$new->attributes['value'] = $value;
return $new;
}
}