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

ConfigurableScoper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A withWhitelistedFiles() 0 14 2
A scope() 0 4 1
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