~ballot/wordpress/openstack-objectstorage-breaking-insight

« back to all changes in this revision

Viewing changes to vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/PHP.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
 * Uses var_export() to write a PHP_CodeCoverage object to a file.
 
13
 *
 
14
 * @category   PHP
 
15
 * @package    CodeCoverage
 
16
 * @author     Sebastian Bergmann <sebastian@phpunit.de>
 
17
 * @author     uyga <iamuyga@gmail.com>
 
18
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 
19
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 
20
 * @link       http://github.com/sebastianbergmann/php-code-coverage
 
21
 * @since      Class available since Release 1.1.0
 
22
 */
 
23
class PHP_CodeCoverage_Report_PHP
 
24
{
 
25
    /**
 
26
     * @param  PHP_CodeCoverage $coverage
 
27
     * @param  string           $target
 
28
     * @return string
 
29
     */
 
30
    public function process(PHP_CodeCoverage $coverage, $target = null)
 
31
    {
 
32
        $filter = $coverage->filter();
 
33
 
 
34
        $output = sprintf(
 
35
            '<?php
 
36
$coverage = new PHP_CodeCoverage;
 
37
$coverage->setData(%s);
 
38
$coverage->setTests(%s);
 
39
 
 
40
$filter = $coverage->filter();
 
41
$filter->setBlacklistedFiles(%s);
 
42
$filter->setWhitelistedFiles(%s);
 
43
 
 
44
return $coverage;',
 
45
            var_export($coverage->getData(true), 1),
 
46
            var_export($coverage->getTests(), 1),
 
47
            var_export($filter->getBlacklistedFiles(), 1),
 
48
            var_export($filter->getWhitelistedFiles(), 1)
 
49
        );
 
50
 
 
51
        if ($target !== null) {
 
52
            return file_put_contents($target, $output);
 
53
        } else {
 
54
            return $output;
 
55
        }
 
56
    }
 
57
}