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

FileWhitelistScoper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A scope() 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 Humbug\PhpScoper\Scoper;
18
use Humbug\PhpScoper\Whitelist;
19
use function array_flip;
20
use function array_key_exists;
21
22
final class FileWhitelistScoper implements Scoper
23
{
24
    private $decoratedScoper;
25
    private $filePaths;
26
27 1
    public function __construct(Scoper $decoratedScoper, string ...$filePaths)
28
    {
29 1
        $this->decoratedScoper = $decoratedScoper;
30 1
        $this->filePaths = array_flip($filePaths);
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 1
    public function scope(string $filePath, string $contents, string $prefix, array $patchers, Whitelist $whitelist): string
37
    {
38 1
        if (array_key_exists($filePath, $this->filePaths)) {
39 1
            return $contents;
40
        }
41
42 1
        return $this->decoratedScoper->scope($filePath, $contents, $prefix, $patchers, $whitelist);
43
    }
44
}
45