comparison vendor/phpunit/php-code-coverage/src/Report/Xml/Project.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php
2 /*
3 * This file is part of the php-code-coverage package.
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
11 namespace SebastianBergmann\CodeCoverage\Report\Xml;
12
13 class Project extends Node
14 {
15 /**
16 * @param string $directory
17 */
18 public function __construct($directory)
19 {
20 $this->init();
21 $this->setProjectSourceDirectory($directory);
22 }
23
24 private function init()
25 {
26 $dom = new \DOMDocument();
27 $dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="http://schema.phpunit.de/coverage/1.0"><build/><project/></phpunit>');
28
29 $this->setContextNode(
30 $dom->getElementsByTagNameNS(
31 'http://schema.phpunit.de/coverage/1.0',
32 'project'
33 )->item(0)
34 );
35 }
36
37 private function setProjectSourceDirectory($name)
38 {
39 $this->getContextNode()->setAttribute('source', $name);
40 }
41
42 /**
43 * @return string
44 */
45 public function getProjectSourceDirectory()
46 {
47 return $this->getContextNode()->getAttribute('source');
48 }
49
50 /**
51 * @return BuildInformation
52 */
53 public function getBuildInformation()
54 {
55 $buildNode = $this->getDom()->getElementsByTagNameNS(
56 'http://schema.phpunit.de/coverage/1.0',
57 'build'
58 )->item(0);
59
60 if (!$buildNode) {
61 $buildNode = $this->getDom()->documentElement->appendChild(
62 $this->getDom()->createElementNS(
63 'http://schema.phpunit.de/coverage/1.0',
64 'build'
65 )
66 );
67 }
68
69 return new BuildInformation($buildNode);
70 }
71
72 public function getTests()
73 {
74 $testsNode = $this->getContextNode()->getElementsByTagNameNS(
75 'http://schema.phpunit.de/coverage/1.0',
76 'tests'
77 )->item(0);
78
79 if (!$testsNode) {
80 $testsNode = $this->getContextNode()->appendChild(
81 $this->getDom()->createElementNS(
82 'http://schema.phpunit.de/coverage/1.0',
83 'tests'
84 )
85 );
86 }
87
88 return new Tests($testsNode);
89 }
90
91 public function asDom()
92 {
93 return $this->getDom();
94 }
95 }