ComposeHtmlAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 3
1
<?php
2
declare(strict_types=1);
3
4
namespace kosuha606\HtmlUniParser\action;
5
6
use kosuha606\HtmlUniParser\HtmlUniParser;
7
8
/**
9
 * @package kosuha606\HtmlUniParser\action
10
 */
11
class ComposeHtmlAction extends AbstractLogicAction
12
{
13
    /**
14
     * @return mixed|string|void
15
     */
16
    public function run()
17
    {
18
        /** @var HtmlUniParser $htmlParserInst */
19
        $htmlParserInst = $this->args[0];
20
        $node = $this->args[1];
21
        if ($htmlParserInst->isForceOuterHtml()) {
22
            return $htmlParserInst->queryOuterHtml($node);
23
        }
24
        $innerHTML = '';
25
        $children = $node->childNodes;
26
        foreach ($children as $child) {
27
            $innerHTML .= $child->ownerDocument->saveXML($child);
28
        }
29
30
        return $innerHTML;
31
    }
32
}