Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
20.00% covered (danger)
20.00%
1 / 5
25.00% covered (danger)
25.00%
1 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
DocumentFragment
20.00% covered (danger)
20.00%
1 / 5
25.00% covered (danger)
25.00%
1 / 4
12.19
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 nodeType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 nodeName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 shallowClone
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Html\Dom;
6
7/**
8 * A lightweight container that holds a subtree without participating in the
9 * main document tree. Used by Parser::parseFragment and by ShadowRoot.
10 */
11class DocumentFragment extends Node
12{
13    public function __construct(Document $ownerDocument)
14    {
15        parent::__construct($ownerDocument);
16    }
17
18    public function nodeType(): NodeType
19    {
20        return NodeType::DocumentFragment;
21    }
22
23    public function nodeName(): string
24    {
25        return '#document-fragment';
26    }
27
28    protected function shallowClone(): static
29    {
30        // ShadowRoot, the only subclass with an incompatible constructor,
31        // overrides shallowClone to throw — so new static() here is reachable
32        // only for DocumentFragment itself.
33        /** @phpstan-ignore-next-line new.static */
34        $copy = new static($this->ownerDocument);
35        /** @var static $copy */
36        return $copy;
37    }
38}