generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHasMaxLength.php
31 lines (27 loc) · 922 Bytes
/
HasMaxLength.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
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute\FormControl;
/**
* Is used by widgets that implement the maxlength method.
*/
trait HasMaxLength
{
/**
* Set the maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter
* into a tag input.
*
* If no maxlength is specified, or an invalid value is specified, the tag input has no maximum length.
*
* @param int $value The maximum number of characters (as UTF-16 code units) the user can enter into a tag input.
*
* @return static A new instance of the current class with the specified maximum length.
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-maxlength
*/
public function maxlength(int $value): static
{
$new = clone $this;
$new->attributes['maxlength'] = $value;
return $new;
}
}