Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/php-code-coverage/src/Report/Xml/File.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 File | |
14 { | |
15 /** | |
16 * @var \DOMDocument | |
17 */ | |
18 private $dom; | |
19 | |
20 /** | |
21 * @var \DOMElement | |
22 */ | |
23 private $contextNode; | |
24 | |
25 public function __construct(\DOMElement $context) | |
26 { | |
27 $this->dom = $context->ownerDocument; | |
28 $this->contextNode = $context; | |
29 } | |
30 | |
31 /** | |
32 * @return \DOMElement | |
33 */ | |
34 protected function getContextNode() | |
35 { | |
36 return $this->contextNode; | |
37 } | |
38 | |
39 /** | |
40 * @return \DOMDocument | |
41 */ | |
42 protected function getDomDocument() | |
43 { | |
44 return $this->dom; | |
45 } | |
46 | |
47 public function getTotals() | |
48 { | |
49 $totalsContainer = $this->contextNode->firstChild; | |
50 | |
51 if (!$totalsContainer) { | |
52 $totalsContainer = $this->contextNode->appendChild( | |
53 $this->dom->createElementNS( | |
54 'http://schema.phpunit.de/coverage/1.0', | |
55 'totals' | |
56 ) | |
57 ); | |
58 } | |
59 | |
60 return new Totals($totalsContainer); | |
61 } | |
62 | |
63 public function getLineCoverage($line) | |
64 { | |
65 $coverage = $this->contextNode->getElementsByTagNameNS( | |
66 'http://schema.phpunit.de/coverage/1.0', | |
67 'coverage' | |
68 )->item(0); | |
69 | |
70 if (!$coverage) { | |
71 $coverage = $this->contextNode->appendChild( | |
72 $this->dom->createElementNS( | |
73 'http://schema.phpunit.de/coverage/1.0', | |
74 'coverage' | |
75 ) | |
76 ); | |
77 } | |
78 | |
79 $lineNode = $coverage->appendChild( | |
80 $this->dom->createElementNS( | |
81 'http://schema.phpunit.de/coverage/1.0', | |
82 'line' | |
83 ) | |
84 ); | |
85 | |
86 return new Coverage($lineNode, $line); | |
87 } | |
88 } |