Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of phpunit/php-code-coverage.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianBergmann\CodeCoverage\Report\Xml;
11
 
12
use DOMElement;
13
 
14
/**
15
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
16
 */
17
final class Unit
18
{
19
    /**
20
     * @var DOMElement
21
     */
22
    private $contextNode;
23
 
24
    public function __construct(DOMElement $context, string $name)
25
    {
26
        $this->contextNode = $context;
27
 
28
        $this->setName($name);
29
    }
30
 
31
    public function setLines(int $start, int $executable, int $executed): void
32
    {
33
        $this->contextNode->setAttribute('start', (string) $start);
34
        $this->contextNode->setAttribute('executable', (string) $executable);
35
        $this->contextNode->setAttribute('executed', (string) $executed);
36
    }
37
 
38
    public function setCrap(float $crap): void
39
    {
40
        $this->contextNode->setAttribute('crap', (string) $crap);
41
    }
42
 
43
    public function setNamespace(string $namespace): void
44
    {
45
        $node = $this->contextNode->getElementsByTagNameNS(
46
            'https://schema.phpunit.de/coverage/1.0',
47
            'namespace'
48
        )->item(0);
49
 
50
        if (!$node) {
51
            $node = $this->contextNode->appendChild(
52
                $this->contextNode->ownerDocument->createElementNS(
53
                    'https://schema.phpunit.de/coverage/1.0',
54
                    'namespace'
55
                )
56
            );
57
        }
58
 
59
        $node->setAttribute('name', $namespace);
60
    }
61
 
62
    public function addMethod(string $name): Method
63
    {
64
        $node = $this->contextNode->appendChild(
65
            $this->contextNode->ownerDocument->createElementNS(
66
                'https://schema.phpunit.de/coverage/1.0',
67
                'method'
68
            )
69
        );
70
 
71
        return new Method($node, $name);
72
    }
73
 
74
    private function setName(string $name): void
75
    {
76
        $this->contextNode->setAttribute('name', $name);
77
    }
78
}