FileWhitelistScoper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 1
b 0
f 0
ccs 4
cts 4
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A scope() 0 7 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 array_key_exists;
18
use function func_get_args;
19
use function Safe\array_flip;
20
21
final class FileWhitelistScoper implements Scoper
22
{
23
    private Scoper $decoratedScoper;
24
    private array $filePaths;
25
26
    public function __construct(Scoper $decoratedScoper, string ...$filePaths)
27
    {
28 1
        $this->decoratedScoper = $decoratedScoper;
29
        $this->filePaths = array_flip($filePaths);
0 ignored issues
show
Deprecated Code introduced by
The function Safe\array_flip() has been deprecated: The Safe version of this function is no longer needed in PHP 8.0+ ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

29
        $this->filePaths = /** @scrutinizer ignore-deprecated */ array_flip($filePaths);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
30 1
    }
31 1
32
    public function scope(string $filePath, string $contents): string
33
    {
34
        if (array_key_exists($filePath, $this->filePaths)) {
35
            return $contents;
36
        }
37 1
38
        return $this->decoratedScoper->scope(...func_get_args());
39 1
    }
40
}
41