ConfigurableScoper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 24
rs 10
c 1
b 0
f 0
ccs 9
cts 10
cp 0.9
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A scope() 0 3 1
A __construct() 0 3 1
A withWhitelistedFiles() 0 8 2
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 function count;
18
use function func_get_args;
19
20
/**
21
 * @deprecated since 0.16. Will be removed in 0.17.
22
 */
23
final class ConfigurableScoper implements Scoper
24
{
25 2
    private Scoper $decoratedScoper;
26
27 2
    public function __construct(Scoper $decoratedScoper)
28
    {
29
        $this->decoratedScoper = $decoratedScoper;
30 1
    }
31
32 1
    public function withWhitelistedFiles(string ...$whitelistedFiles): self
33
    {
34 1
        return count($whitelistedFiles) === 0
35
            ? $this
36 1
            : new self(
37 1
                new FileWhitelistScoper(
38 1
                    clone $this,
39 1
                    ...$whitelistedFiles,
40
                ),
41
            );
42
    }
43
44
    public function scope(string $filePath, string $contents): string
45
    {
46
        return $this->decoratedScoper->scope(...func_get_args());
47
    }
48
}
49