3 * This file is part of the PHP_CodeCoverage package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * @since Class available since Release 2.0.0
14 class PHP_CodeCoverage_Report_XML_Node
26 public function __construct(DOMElement $context)
28 $this->setContextNode($context);
31 protected function setContextNode(DOMElement $context)
33 $this->dom = $context->ownerDocument;
34 $this->contextNode = $context;
37 public function getDom()
42 protected function getContextNode()
44 return $this->contextNode;
47 public function getTotals()
49 $totalsContainer = $this->getContextNode()->firstChild;
51 if (!$totalsContainer) {
52 $totalsContainer = $this->getContextNode()->appendChild(
53 $this->dom->createElementNS(
54 'http://schema.phpunit.de/coverage/1.0',
60 return new PHP_CodeCoverage_Report_XML_Totals($totalsContainer);
63 public function addDirectory($name)
65 $dirNode = $this->getDom()->createElementNS(
66 'http://schema.phpunit.de/coverage/1.0',
70 $dirNode->setAttribute('name', $name);
71 $this->getContextNode()->appendChild($dirNode);
73 return new PHP_CodeCoverage_Report_XML_Directory($dirNode);
76 public function addFile($name, $href)
78 $fileNode = $this->getDom()->createElementNS(
79 'http://schema.phpunit.de/coverage/1.0',
83 $fileNode->setAttribute('name', $name);
84 $fileNode->setAttribute('href', $href);
85 $this->getContextNode()->appendChild($fileNode);
87 return new PHP_CodeCoverage_Report_XML_File($fileNode);