Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Anchor
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 href
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHref
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 target
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 blank
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Epic64\Elem\Elements;
6
7use Epic64\Elem\Element;
8
9class Anchor extends Element
10{
11    public function __construct(string $href, ?string $text = null)
12    {
13        parent::__construct('a', $text);
14        $this->element->setAttribute('href', $href);
15    }
16
17    public function href(string $href): static
18    {
19        return $this->attr('href', $href);
20    }
21
22    public function getHref(): string
23    {
24        return $this->getAttr('href');
25    }
26
27    public function target(string $target): static
28    {
29        return $this->attr('target', $target);
30    }
31
32    public function blank(): static
33    {
34        return $this->target('_blank')->attr('rel', 'noopener noreferrer');
35    }
36}