a6fe7ecf0440a12c8642241606422bee90123265
[yaffs-website] / vendor / phpunit / php-code-coverage / src / CodeCoverage / Report / XML / File / Report.php
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_Report extends PHP_CodeCoverage_Report_XML_File
15 {
16     public function __construct($name)
17     {
18         $this->dom = new DOMDocument;
19         $this->dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="http://schema.phpunit.de/coverage/1.0"><file /></phpunit>');
20
21         $this->contextNode = $this->dom->getElementsByTagNameNS(
22             'http://schema.phpunit.de/coverage/1.0',
23             'file'
24         )->item(0);
25
26         $this->setName($name);
27     }
28
29     private function setName($name)
30     {
31         $this->contextNode->setAttribute('name', $name);
32     }
33
34     public function asDom()
35     {
36         return $this->dom;
37     }
38
39     public function getFunctionObject($name)
40     {
41         $node = $this->contextNode->appendChild(
42             $this->dom->createElementNS(
43                 'http://schema.phpunit.de/coverage/1.0',
44                 'function'
45             )
46         );
47
48         return new PHP_CodeCoverage_Report_XML_File_Method($node, $name);
49     }
50
51     public function getClassObject($name)
52     {
53         return $this->getUnitObject('class', $name);
54     }
55
56     public function getTraitObject($name)
57     {
58         return $this->getUnitObject('trait', $name);
59     }
60
61     private function getUnitObject($tagName, $name)
62     {
63         $node = $this->contextNode->appendChild(
64             $this->dom->createElementNS(
65                 'http://schema.phpunit.de/coverage/1.0',
66                 $tagName
67             )
68         );
69
70         return new PHP_CodeCoverage_Report_XML_File_Unit($node, $name);
71     }
72 }