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
 
14
/**
15
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
16
 */
17
final class Project extends Node
18
{
19
    public function __construct(string $directory)
20
    {
21
        $this->init();
22
        $this->setProjectSourceDirectory($directory);
23
    }
24
 
25
    public function projectSourceDirectory(): string
26
    {
27
        return $this->contextNode()->getAttribute('source');
28
    }
29
 
30
    public function buildInformation(): BuildInformation
31
    {
32
        $buildNode = $this->dom()->getElementsByTagNameNS(
33
            'https://schema.phpunit.de/coverage/1.0',
34
            'build'
35
        )->item(0);
36
 
37
        if (!$buildNode) {
38
            $buildNode = $this->dom()->documentElement->appendChild(
39
                $this->dom()->createElementNS(
40
                    'https://schema.phpunit.de/coverage/1.0',
41
                    'build'
42
                )
43
            );
44
        }
45
 
46
        return new BuildInformation($buildNode);
47
    }
48
 
49
    public function tests(): Tests
50
    {
51
        $testsNode = $this->contextNode()->getElementsByTagNameNS(
52
            'https://schema.phpunit.de/coverage/1.0',
53
            'tests'
54
        )->item(0);
55
 
56
        if (!$testsNode) {
57
            $testsNode = $this->contextNode()->appendChild(
58
                $this->dom()->createElementNS(
59
                    'https://schema.phpunit.de/coverage/1.0',
60
                    'tests'
61
                )
62
            );
63
        }
64
 
65
        return new Tests($testsNode);
66
    }
67
 
68
    public function asDom(): DOMDocument
69
    {
70
        return $this->dom();
71
    }
72
 
73
    private function init(): void
74
    {
75
        $dom = new DOMDocument;
76
        $dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="https://schema.phpunit.de/coverage/1.0"><build/><project/></phpunit>');
77
 
78
        $this->setContextNode(
79
            $dom->getElementsByTagNameNS(
80
                'https://schema.phpunit.de/coverage/1.0',
81
                'project'
82
            )->item(0)
83
        );
84
    }
85
 
86
    private function setProjectSourceDirectory(string $name): void
87
    {
88
        $this->contextNode()->setAttribute('source', $name);
89
    }
90
}