ConfigurableScoper::withWhitelistedFiles()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 6
cts 7
cp 0.8571
crap 2.0116
rs 10
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