Passed
Push — master ( f59561...f05f0a )
by Théo
03:05
created

ConfigurableScoper::withWhitelistedFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 6
rs 10
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
    public function __construct(Scoper $decoratedScoper)
25
    {
26
        $this->decoratedScoper = $decoratedScoper;
27
    }
28
29
    public function withWhitelistedFiles(string ...$whitelistedFiles): self
30
    {
31
        $self = clone $this;
32
33
        return [] === $whitelistedFiles ? $self : new self(new FileWhitelistScoper($self));
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string
40
    {
41
        return $this->decoratedScoper->scope($filePath, $contents, $prefix, $patchers, $whitelist);
42
    }
43
}
44