Passed
Pull Request — master (#11)
by Steve
01:59
created

WhiteSpaceNode   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A isWhiteSpace() 0 10 5
1
<?php
2
/**
3
 * (c) Steve Nebes <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
declare(strict_types=1);
10
11
namespace SN\DaisyDiff\Html\Dom;
12
13
/**
14
 * Represents whitespace in the HTML file.
15
 */
16
class WhiteSpaceNode extends TextNode
17
{
18
    /**
19
     * @param TagNode|null $parent
20
     * @param string       $s
21
     * @param Node|null     $like
22
     */
23 14
    public function __construct(?TagNode $parent, string $s, ?Node $like)
24
    {
25 14
        parent::__construct($parent, $s);
26
27 14
        if ($like instanceof TextNode) {
28 14
            $newModification = clone $like->getModification();
29 14
            $newModification->setFirstOfId(false);
30 14
            $this->setModification($newModification);
31
        }
32 14
    }
33
34
    /**
35
     * @param string $c
36
     * @return bool
37
     */
38 23
    public static function isWhiteSpace(string $c): bool
39
    {
40 23
        switch ($c) {
41 23
            case ' ':
42 23
            case "\t":
43 23
            case "\r":
44 23
            case "\n":
45 16
                return true;
46
            default:
47 23
                return false;
48
        }
49
    }
50
}
51