Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/File.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the PHP_CodeCoverage 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 /** | |
12 * @since Class available since Release 2.0.0 | |
13 */ | |
14 class PHP_CodeCoverage_Report_XML_File | |
15 { | |
16 /** | |
17 * @var DOMDocument | |
18 */ | |
19 protected $dom; | |
20 | |
21 /** | |
22 * @var DOMElement | |
23 */ | |
24 protected $contextNode; | |
25 | |
26 public function __construct(DOMElement $context) | |
27 { | |
28 $this->dom = $context->ownerDocument; | |
29 $this->contextNode = $context; | |
30 } | |
31 | |
32 public function getTotals() | |
33 { | |
34 $totalsContainer = $this->contextNode->firstChild; | |
35 | |
36 if (!$totalsContainer) { | |
37 $totalsContainer = $this->contextNode->appendChild( | |
38 $this->dom->createElementNS( | |
39 'http://schema.phpunit.de/coverage/1.0', | |
40 'totals' | |
41 ) | |
42 ); | |
43 } | |
44 | |
45 return new PHP_CodeCoverage_Report_XML_Totals($totalsContainer); | |
46 } | |
47 | |
48 public function getLineCoverage($line) | |
49 { | |
50 $coverage = $this->contextNode->getElementsByTagNameNS( | |
51 'http://schema.phpunit.de/coverage/1.0', | |
52 'coverage' | |
53 )->item(0); | |
54 | |
55 if (!$coverage) { | |
56 $coverage = $this->contextNode->appendChild( | |
57 $this->dom->createElementNS( | |
58 'http://schema.phpunit.de/coverage/1.0', | |
59 'coverage' | |
60 ) | |
61 ); | |
62 } | |
63 | |
64 $lineNode = $coverage->appendChild( | |
65 $this->dom->createElementNS( | |
66 'http://schema.phpunit.de/coverage/1.0', | |
67 'line' | |
68 ) | |
69 ); | |
70 | |
71 return new PHP_CodeCoverage_Report_XML_File_Coverage($lineNode, $line); | |
72 } | |
73 } |