Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
A_
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 href
100.00% covered (success)
100.00%
2 / 2
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
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Svg;
6
7/**
8 * SVG 2 §12.1.1 — `<a>` element. A container that wraps any
9 * SVG content and turns the wrapped region into a hyperlink.
10 *
11 *   <a href="https://example.com">
12 *     <rect x="10" y="10" width="80" height="20"/>
13 *   </a>
14 *
15 * The `href` (or legacy `xlink:href`) attribute is the link
16 * target; `target`, `download`, `rel`, `hreflang`, `type`,
17 * `referrerpolicy` are surface attributes preserved on the
18 * element but only `href` and `target` are honoured at print
19 * time. Class is named `A_` because `A` clashes with the
20 * single-letter PHPStan IGNORE convention; SVG callers see
21 * `<a>` as usual.
22 */
23final class A_ extends Element
24{
25    public function __construct()
26    {
27        parent::__construct('a');
28    }
29
30    public function href(): ?string
31    {
32        return $this->getAttribute('href')
33            ?? $this->getAttribute('xlink:href');
34    }
35
36    public function target(): ?string
37    {
38        return $this->getAttribute('target');
39    }
40}