Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/php-code-coverage/src/Report/Xml/Report.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 Report extends File | |
14 { | |
15 public function __construct($name) | |
16 { | |
17 $dom = new \DOMDocument(); | |
18 $dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="http://schema.phpunit.de/coverage/1.0"><file /></phpunit>'); | |
19 | |
20 $contextNode = $dom->getElementsByTagNameNS( | |
21 'http://schema.phpunit.de/coverage/1.0', | |
22 'file' | |
23 )->item(0); | |
24 | |
25 parent::__construct($contextNode); | |
26 $this->setName($name); | |
27 } | |
28 | |
29 private function setName($name) | |
30 { | |
31 $this->getContextNode()->setAttribute('name', \basename($name)); | |
32 $this->getContextNode()->setAttribute('path', \dirname($name)); | |
33 } | |
34 | |
35 public function asDom() | |
36 { | |
37 return $this->getDomDocument(); | |
38 } | |
39 | |
40 public function getFunctionObject($name) | |
41 { | |
42 $node = $this->getContextNode()->appendChild( | |
43 $this->getDomDocument()->createElementNS( | |
44 'http://schema.phpunit.de/coverage/1.0', | |
45 'function' | |
46 ) | |
47 ); | |
48 | |
49 return new Method($node, $name); | |
50 } | |
51 | |
52 public function getClassObject($name) | |
53 { | |
54 return $this->getUnitObject('class', $name); | |
55 } | |
56 | |
57 public function getTraitObject($name) | |
58 { | |
59 return $this->getUnitObject('trait', $name); | |
60 } | |
61 | |
62 private function getUnitObject($tagName, $name) | |
63 { | |
64 $node = $this->getContextNode()->appendChild( | |
65 $this->getDomDocument()->createElementNS( | |
66 'http://schema.phpunit.de/coverage/1.0', | |
67 $tagName | |
68 ) | |
69 ); | |
70 | |
71 return new Unit($node, $name); | |
72 } | |
73 | |
74 public function getSource() | |
75 { | |
76 $source = $this->getContextNode()->getElementsByTagNameNS( | |
77 'http://schema.phpunit.de/coverage/1.0', | |
78 'source' | |
79 )->item(0); | |
80 | |
81 if (!$source) { | |
82 $source = $this->getContextNode()->appendChild( | |
83 $this->getDomDocument()->createElementNS( | |
84 'http://schema.phpunit.de/coverage/1.0', | |
85 'source' | |
86 ) | |
87 ); | |
88 } | |
89 | |
90 return new Source($source); | |
91 } | |
92 } |