@@ 14-52 (lines=39) @@ | ||
11 | * Class Embed |
|
12 | * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed |
|
13 | */ |
|
14 | final class Embed extends AbstractElement |
|
15 | { |
|
16 | public function __construct(AttributeSet $attributes = null) |
|
17 | { |
|
18 | $this->attributes = $attributes ?? new AttributeSet(); |
|
19 | $this->tag = new EmptyTag('embed', $attributes); |
|
20 | } |
|
21 | ||
22 | public function withAttribute(string $name, string $value = null): Embed |
|
23 | { |
|
24 | if ($value) { |
|
25 | $attribute = new StandardAttribute($name, $value); |
|
26 | } else { |
|
27 | $attribute = new BooleanAttribute($name); |
|
28 | } |
|
29 | ||
30 | return new Embed($this->attributes->add($attribute)); |
|
31 | } |
|
32 | ||
33 | public function withHeight(int $pixels): Embed |
|
34 | { |
|
35 | return $this->withAttribute('height', $pixels); |
|
36 | } |
|
37 | ||
38 | public function withWidth(int $pixels): Embed |
|
39 | { |
|
40 | return $this->withAttribute('width', $pixels); |
|
41 | } |
|
42 | ||
43 | public function withSrc(string $url): Embed |
|
44 | { |
|
45 | return $this->withAttribute('src', $url); |
|
46 | } |
|
47 | ||
48 | public function withType(string $mime): Embed |
|
49 | { |
|
50 | return $this->withAttribute('type', $mime); |
|
51 | } |
|
52 | } |
|
53 |
@@ 14-62 (lines=49) @@ | ||
11 | * Class Meta |
|
12 | * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta |
|
13 | */ |
|
14 | final class Meta extends AbstractElement |
|
15 | { |
|
16 | public function __construct(AttributeSet $attributes = null) |
|
17 | { |
|
18 | $this->attributes = $attributes ?? new AttributeSet(); |
|
19 | $this->tag = new EmptyTag('meta', $attributes); |
|
20 | } |
|
21 | ||
22 | public function withAttribute(string $name, string $value = null): Meta |
|
23 | { |
|
24 | if ($value) { |
|
25 | $attribute = new StandardAttribute($name, $value); |
|
26 | } else { |
|
27 | $attribute = new BooleanAttribute($name); |
|
28 | } |
|
29 | ||
30 | return new Meta($this->attributes->add($attribute)); |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param string $charset |
|
35 | * @return Meta |
|
36 | * @see http://www.iana.org/assignments/character-sets |
|
37 | */ |
|
38 | public function withCharset(string $charset): Meta |
|
39 | { |
|
40 | return $this->withAttribute('charset', $charset); |
|
41 | } |
|
42 | ||
43 | public function withContent(string $content): Meta |
|
44 | { |
|
45 | return $this->withAttribute('content', $content); |
|
46 | } |
|
47 | ||
48 | public function withHttpEquiv(string $httpEquiv): Meta |
|
49 | { |
|
50 | return $this->withAttribute('http-equiv', $httpEquiv); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @param string $name |
|
55 | * @return Meta |
|
56 | * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-name |
|
57 | */ |
|
58 | public function withName(string $name): Meta |
|
59 | { |
|
60 | return $this->withAttribute('name', $name); |
|
61 | } |
|
62 | } |
|
63 |
@@ 14-57 (lines=44) @@ | ||
11 | * Class Track |
|
12 | * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track |
|
13 | */ |
|
14 | final class Track extends AbstractElement |
|
15 | { |
|
16 | public function __construct(AttributeSet $attributes = null) |
|
17 | { |
|
18 | $this->attributes = $attributes ?? new AttributeSet(); |
|
19 | $this->tag = new EmptyTag('track', $attributes); |
|
20 | } |
|
21 | ||
22 | public function withAttribute(string $name, string $value = null): Track |
|
23 | { |
|
24 | if ($value) { |
|
25 | $attribute = new StandardAttribute($name, $value); |
|
26 | } else { |
|
27 | $attribute = new BooleanAttribute($name); |
|
28 | } |
|
29 | ||
30 | return new Track($this->attributes->add($attribute)); |
|
31 | } |
|
32 | ||
33 | public function withDefault(): Track |
|
34 | { |
|
35 | return $this->withAttribute('default'); |
|
36 | } |
|
37 | ||
38 | public function withKind(string $kind = 'subtitles'): Track |
|
39 | { |
|
40 | return $this->withAttribute('kind', $kind); |
|
41 | } |
|
42 | ||
43 | public function withLabel(string $label): Track |
|
44 | { |
|
45 | return $this->withAttribute('label', $label); |
|
46 | } |
|
47 | ||
48 | public function withSrc(string $url): Track |
|
49 | { |
|
50 | return $this->withAttribute('src', $url); |
|
51 | } |
|
52 | ||
53 | public function withSrcLang(string $lang): Track |
|
54 | { |
|
55 | return $this->withAttribute('srclang', $lang); |
|
56 | } |
|
57 | } |
|
58 |