Total Complexity | 8 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | abstract class BaseParser |
||
11 | { |
||
12 | /** |
||
13 | * @var CheckNode |
||
14 | */ |
||
15 | protected $manager; |
||
16 | |||
17 | /** |
||
18 | * @var Doc |
||
19 | */ |
||
20 | public $doc; |
||
21 | |||
22 | public function __construct(CheckNode $manager) |
||
26 | } |
||
27 | |||
28 | public function setDocFactory(Doc $factory): void |
||
29 | { |
||
30 | $this->doc = $factory; |
||
31 | } |
||
32 | |||
33 | protected function stringify(\DOMNode $node): string |
||
34 | { |
||
35 | return $this->doc->stringify($node); |
||
36 | } |
||
37 | |||
38 | protected function stringifyList(\DOMNodeList $nodes): array |
||
39 | { |
||
40 | return $this->doc->stringifyFromList($nodes); |
||
41 | } |
||
42 | |||
43 | protected function collect(callable $test, \DOMNode $node, \DOMDocument $carry): \DOMNodeList |
||
44 | { |
||
45 | if ($test($node)) { |
||
46 | $carry->documentElement->appendChild($carry->importNode($node, true)); |
||
47 | } |
||
48 | |||
49 | return null !== $node->nextSibling ? |
||
50 | $this->collect($test, $node->nextSibling, $carry) : $carry->documentElement->childNodes; |
||
51 | } |
||
52 | |||
53 | protected function containerDOM(): \DOMDocument |
||
59 | } |
||
60 | } |
||
61 |