Passed
Push — master ( 981639...0d07bf )
by Steve
47s
created

ChangeText   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

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

5 Methods

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