Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Link | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| href | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| rel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| type | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| media | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| sizes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Epic64\Elem\Elements; |
| 6 | |
| 7 | use Epic64\Elem\Element; |
| 8 | |
| 9 | /** |
| 10 | * Represents a <link> element for linking external resources. |
| 11 | * |
| 12 | * Note: For stylesheets, you probably want to use the stylesheet() helper function instead, |
| 13 | * which provides a more convenient API: stylesheet('/css/style.css') |
| 14 | */ |
| 15 | class Link extends Element |
| 16 | { |
| 17 | public function __construct(?string $href = null, ?string $rel = null) |
| 18 | { |
| 19 | parent::__construct('link'); |
| 20 | if ($href !== null) { |
| 21 | $this->element->setAttribute('href', $href); |
| 22 | } |
| 23 | if ($rel !== null) { |
| 24 | $this->element->setAttribute('rel', $rel); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public function href(string $href): static |
| 29 | { |
| 30 | return $this->attr('href', $href); |
| 31 | } |
| 32 | |
| 33 | public function rel(string $rel): static |
| 34 | { |
| 35 | return $this->attr('rel', $rel); |
| 36 | } |
| 37 | |
| 38 | public function type(string $type): static |
| 39 | { |
| 40 | return $this->attr('type', $type); |
| 41 | } |
| 42 | |
| 43 | public function media(string $media): static |
| 44 | { |
| 45 | return $this->attr('media', $media); |
| 46 | } |
| 47 | |
| 48 | public function sizes(string $sizes): static |
| 49 | { |
| 50 | return $this->attr('sizes', $sizes); |
| 51 | } |
| 52 | } |