generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHasRel.php
59 lines (53 loc) · 1.66 KB
/
HasRel.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute;
use UIAwesome\Html\Helper\Validator;
/**
* Is used by widgets that implement the rel method.
*/
trait HasRel
{
/**
* Set the rel attribute specifies the relationship between the current document and the linked document.
*
* @param string $value The relationship of the linked URL as space-separated link types.
*
* @throws \InvalidArgumentException If the value is not one of the allowed values. Allowed values are:
* `alternate`, `author`, `bookmark`, `help`, `icon`, `license`, `next`, `nofollow`, `noopener`, `noreferrer`,
* `pingback`, `preconnect`, `prefetch`, `preload`, `prerender`, `prev`, `search`, `sidebar`, `stylesheet`, `tag`.
*
* @return static A new instance of the current class with the specified rel value.
*
* @link https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-rel
*/
public function rel(string $value): static
{
Validator::inList(
$value,
'Invalid value "%s" for the rel attribute. Allowed values are: "%s".',
'alternate',
'author',
'bookmark',
'help',
'icon',
'license',
'next',
'nofollow',
'noopener',
'noreferrer',
'pingback',
'preconnect',
'prefetch',
'preload',
'prerender',
'prev',
'search',
'sidebar',
'stylesheet',
'tag',
);
$new = clone $this;
$new->attributes['rel'] = $value;
return $new;
}
}