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 DOMDocument;
13
use DOMElement;
14
 
15
/**
16
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
17
 */
18
class File
19
{
20
    /**
21
     * @var DOMDocument
22
     */
23
    private $dom;
24
 
25
    /**
26
     * @var DOMElement
27
     */
28
    private $contextNode;
29
 
30
    public function __construct(DOMElement $context)
31
    {
32
        $this->dom         = $context->ownerDocument;
33
        $this->contextNode = $context;
34
    }
35
 
36
    public function totals(): Totals
37
    {
38
        $totalsContainer = $this->contextNode->firstChild;
39
 
40
        if (!$totalsContainer) {
41
            $totalsContainer = $this->contextNode->appendChild(
42
                $this->dom->createElementNS(
43
                    'https://schema.phpunit.de/coverage/1.0',
44
                    'totals'
45
                )
46
            );
47
        }
48
 
49
        return new Totals($totalsContainer);
50
    }
51
 
52
    public function lineCoverage(string $line): Coverage
53
    {
54
        $coverage = $this->contextNode->getElementsByTagNameNS(
55
            'https://schema.phpunit.de/coverage/1.0',
56
            'coverage'
57
        )->item(0);
58
 
59
        if (!$coverage) {
60
            $coverage = $this->contextNode->appendChild(
61
                $this->dom->createElementNS(
62
                    'https://schema.phpunit.de/coverage/1.0',
63
                    'coverage'
64
                )
65
            );
66
        }
67
 
68
        $lineNode = $coverage->appendChild(
69
            $this->dom->createElementNS(
70
                'https://schema.phpunit.de/coverage/1.0',
71
                'line'
72
            )
73
        );
74
 
75
        return new Coverage($lineNode, $line);
76
    }
77
 
78
    protected function contextNode(): DOMElement
79
    {
80
        return $this->contextNode;
81
    }
82
 
83
    protected function dom(): DOMDocument
84
    {
85
        return $this->dom;
86
    }
87
}