Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Attr
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
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
 qualifiedName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Html\Dom;
6
7/**
8 * Attribute value object. Attributes are immutable — to change an attribute,
9 * call Element::setAttribute() which constructs a new Attr and replaces the
10 * existing entry on the element's attribute map.
11 *
12 * Namespace defaults to the HTML namespace; foreign-element attributes (SVG,
13 * MathML) carry their own namespace and optionally a prefix.
14 */
15final readonly class Attr
16{
17    public function __construct(
18        public string $localName,
19        public string $value,
20        public string $namespaceURI = Document::HTML_NS,
21        public ?string $prefix = null,
22    ) {}
23
24    /**
25     * Qualified name: "prefix:localName" if prefix is set, otherwise localName.
26     */
27    public function qualifiedName(): string
28    {
29        return $this->prefix !== null ? $this->prefix . ':' . $this->localName : $this->localName;
30    }
31}