Completed
Push — master ( b1adff...449a59 )
by Théo
02:23
created

PatchScoper::scope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 3
dl 0
loc 12
ccs 0
cts 8
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper\Scoper;
16
17
use Humbug\PhpScoper\Scoper;
18
19
final class PatchScoper implements Scoper
20
{
21
    private $decoratedScoper;
22
23
    public function __construct(Scoper $decoratedScoper)
24
    {
25
        $this->decoratedScoper = $decoratedScoper;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function scope(string $filePath, string $prefix, array $patchers): string
32
    {
33
        $content = $this->decoratedScoper->scope($filePath, $prefix, $patchers);
34
35
        return array_reduce(
36
            $patchers,
37
            function (string $content, callable $patcher) use ($filePath, $prefix): string {
38
                return $patcher($filePath, $prefix, $content);
39
            },
40
            $content
41
        );
42
    }
43
}
44