~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Node.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @category   PHP
 
13
 * @package    CodeCoverage
 
14
 * @author     Arne Blankerts <arne@blankerts.de>
 
15
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 
16
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 
17
 * @link       http://github.com/sebastianbergmann/php-code-coverage
 
18
 * @since      Class available since Release 2.0.0
 
19
 */
 
20
class PHP_CodeCoverage_Report_XML_Node
 
21
{
 
22
    /**
 
23
     * @var DOMDocument
 
24
     */
 
25
    private $dom;
 
26
 
 
27
    /**
 
28
     * @var DOMElement
 
29
     */
 
30
    private $contextNode;
 
31
 
 
32
    public function __construct(DOMElement $context)
 
33
    {
 
34
        $this->setContextNode($context);
 
35
    }
 
36
 
 
37
    protected function setContextNode(DOMElement $context)
 
38
    {
 
39
        $this->dom         = $context->ownerDocument;
 
40
        $this->contextNode = $context;
 
41
    }
 
42
 
 
43
    public function getDom()
 
44
    {
 
45
        return $this->dom;
 
46
    }
 
47
 
 
48
    protected function getContextNode()
 
49
    {
 
50
        return $this->contextNode;
 
51
    }
 
52
 
 
53
    public function getTotals()
 
54
    {
 
55
        $totalsContainer = $this->getContextNode()->firstChild;
 
56
 
 
57
        if (!$totalsContainer) {
 
58
            $totalsContainer = $this->getContextNode()->appendChild(
 
59
                $this->dom->createElementNS(
 
60
                    'http://schema.phpunit.de/coverage/1.0', 'totals'
 
61
                )
 
62
            );
 
63
        }
 
64
 
 
65
        return new PHP_CodeCoverage_Report_XML_Totals($totalsContainer);
 
66
    }
 
67
 
 
68
    public function addDirectory($name)
 
69
    {
 
70
        $dirNode = $this->getDom()->createElementNS(
 
71
            'http://schema.phpunit.de/coverage/1.0', 'directory'
 
72
        );
 
73
 
 
74
        $dirNode->setAttribute('name', $name);
 
75
        $this->getContextNode()->appendChild($dirNode);
 
76
 
 
77
        return new PHP_CodeCoverage_Report_XML_Directory($dirNode);
 
78
    }
 
79
 
 
80
    public function addFile($name, $href)
 
81
    {
 
82
        $fileNode = $this->getDom()->createElementNS(
 
83
            'http://schema.phpunit.de/coverage/1.0', 'file'
 
84
        );
 
85
 
 
86
        $fileNode->setAttribute('name', $name);
 
87
        $fileNode->setAttribute('href', $href);
 
88
        $this->getContextNode()->appendChild($fileNode);
 
89
 
 
90
        return new PHP_CodeCoverage_Report_XML_File($fileNode);
 
91
    }
 
92
}