Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of phpunit/php-code-coverage.
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
namespace SebastianBergmann\CodeCoverage\Report;
11
 
12
use function dirname;
13
use function file_put_contents;
14
use function serialize;
15
use SebastianBergmann\CodeCoverage\CodeCoverage;
16
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
17
use SebastianBergmann\CodeCoverage\Util\Filesystem;
18
 
19
final class PHP
20
{
21
    public function process(CodeCoverage $coverage, ?string $target = null): string
22
    {
23
        $buffer = "<?php
24
return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL . serialize($coverage) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL . ');';
25
 
26
        if ($target !== null) {
27
            Filesystem::createDirectory(dirname($target));
28
 
29
            if (@file_put_contents($target, $buffer) === false) {
30
                throw new WriteOperationFailedException($target);
31
            }
32
        }
33
 
34
        return $buffer;
35
    }
36
}