Passed
Push — master ( dd4616...6f5052 )
by Steve
36s queued 10s
created

ChangeText::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 40
    public function startElement(string $qName, array $attributes = []): void
28
    {
29 40
        $this->text .= '<' . $qName;
30
31 40
        foreach ($attributes as $attr => $value) {
32 36
            $this->text .= \sprintf(' %s="%s"', $attr, $value);
33
        }
34
35 40
        $this->text .= '>';
36 40
    }
37
38
    /**
39
     * @param string $qName
40
     */
41 40
    public function endElement(string $qName): void
42
    {
43 40
        $this->text .= \sprintf('</%s>', $qName);
44 40
    }
45
46
    /**
47
     * @param string $chars
48
     */
49 33
    public function characters(string $chars): void
50
    {
51 33
        $this->text .= $chars;
52 33
    }
53
54
    /**
55
     * @return string
56
     */
57 38
    public function getText(): string
58
    {
59 38
        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