Passed
Push — master ( 514edf...359688 )
by Théo
02:17
created

ConfigurableScoper::withWhitelistedFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 14
ccs 7
cts 8
cp 0.875
crap 2.0078
rs 9.7998
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
use Humbug\PhpScoper\Whitelist;
19
20
final class ConfigurableScoper implements Scoper
21
{
22
    private $decoratedScoper;
23
24 2
    public function __construct(Scoper $decoratedScoper)
25
    {
26 2
        $this->decoratedScoper = $decoratedScoper;
27
    }
28
29 1
    public function withWhitelistedFiles(string ...$whitelistedFiles): self
30
    {
31 1
        $self = clone $this;
32
33 1
        return [] === $whitelistedFiles
34
            ? $self
35 1
            : new self(
36 1
                new FileWhitelistScoper(
37 1
                    $self,
38 1
                    ...$whitelistedFiles
39
                )
40
            )
41
        ;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47 2
    public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string
48
    {
49 2
        return $this->decoratedScoper->scope($filePath, $contents, $prefix, $patchers, $whitelist);
50
    }
51
}
52