Mercurial > hg > isophonics-drupal-site
annotate vendor/phpunit/php-code-coverage/src/Report/PHP.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
rev | line source |
---|---|
Chris@14 | 1 <?php |
Chris@14 | 2 /* |
Chris@14 | 3 * This file is part of the php-code-coverage package. |
Chris@14 | 4 * |
Chris@14 | 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> |
Chris@14 | 6 * |
Chris@14 | 7 * For the full copyright and license information, please view the LICENSE |
Chris@14 | 8 * file that was distributed with this source code. |
Chris@14 | 9 */ |
Chris@14 | 10 |
Chris@14 | 11 namespace SebastianBergmann\CodeCoverage\Report; |
Chris@14 | 12 |
Chris@14 | 13 use SebastianBergmann\CodeCoverage\CodeCoverage; |
Chris@14 | 14 use SebastianBergmann\CodeCoverage\RuntimeException; |
Chris@14 | 15 |
Chris@14 | 16 /** |
Chris@14 | 17 * Uses var_export() to write a SebastianBergmann\CodeCoverage\CodeCoverage object to a file. |
Chris@14 | 18 */ |
Chris@14 | 19 class PHP |
Chris@14 | 20 { |
Chris@14 | 21 /** |
Chris@14 | 22 * @param CodeCoverage $coverage |
Chris@14 | 23 * @param string $target |
Chris@14 | 24 * |
Chris@14 | 25 * @return string |
Chris@14 | 26 */ |
Chris@14 | 27 public function process(CodeCoverage $coverage, $target = null) |
Chris@14 | 28 { |
Chris@14 | 29 $filter = $coverage->filter(); |
Chris@14 | 30 |
Chris@14 | 31 $buffer = \sprintf( |
Chris@14 | 32 '<?php |
Chris@14 | 33 $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage; |
Chris@14 | 34 $coverage->setData(%s); |
Chris@14 | 35 $coverage->setTests(%s); |
Chris@14 | 36 |
Chris@14 | 37 $filter = $coverage->filter(); |
Chris@14 | 38 $filter->setWhitelistedFiles(%s); |
Chris@14 | 39 |
Chris@14 | 40 return $coverage;', |
Chris@14 | 41 \var_export($coverage->getData(true), 1), |
Chris@14 | 42 \var_export($coverage->getTests(), 1), |
Chris@14 | 43 \var_export($filter->getWhitelistedFiles(), 1) |
Chris@14 | 44 ); |
Chris@14 | 45 |
Chris@14 | 46 if ($target !== null) { |
Chris@14 | 47 if (@\file_put_contents($target, $buffer) === false) { |
Chris@14 | 48 throw new RuntimeException( |
Chris@14 | 49 \sprintf( |
Chris@14 | 50 'Could not write to "%s', |
Chris@14 | 51 $target |
Chris@14 | 52 ) |
Chris@14 | 53 ); |
Chris@14 | 54 } |
Chris@14 | 55 } |
Chris@14 | 56 |
Chris@14 | 57 return $buffer; |
Chris@14 | 58 } |
Chris@14 | 59 } |