ChangeText   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 50
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A endElement() 0 3 1
A getText() 0 3 1
A characters() 0 3 1
A startElement() 0 9 2
A __toString() 0 3 1
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;
12
13
use SN\DaisyDiff\Xml\ContentHandlerInterface;
14
15
/**
16
 * ChangeText model.
17
 */
18
class ChangeText implements ContentHandlerInterface
19
{
20
    /** @var string */
21
    private $text = '';
22
23
    /**
24
     * @param string $qName
25
     * @param array  $attributes
26
     */
27 68
    public function startElement(string $qName, array $attributes = []): void
28
    {
29 68
        $this->text .= '<' . $qName;
30
31 68
        foreach ($attributes as $attr => $value) {
32 63
            $this->text .= \sprintf(' %s="%s"', $attr, $value);
33
        }
34
35 68
        $this->text .= '>';
36 68
    }
37
38
    /**
39
     * @param string $qName
40
     */
41 68
    public function endElement(string $qName): void
42
    {
43 68
        $this->text .= \sprintf('</%s>', $qName);
44 68
    }
45
46
    /**
47
     * @param string $chars
48
     */
49 61
    public function characters(string $chars): void
50
    {
51 61
        $this->text .= $chars;
52 61
    }
53
54
    /**
55
     * @return string
56
     */
57 66
    public function getText(): string
58
    {
59 66
        return $this->text;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 5
    public function __toString(): string
66
    {
67 5
        return $this->getText();
68
    }
69
}
70