ComposeHtmlAction::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
rs 9.9666
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
}