Issues (224)

src/PhpScoper/ExcludedFilesScoper.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\PhpScoper;
16
17
use Humbug\PhpScoper\Scoper\Scoper as PhpScoperScoper;
18
use function array_flip;
19
use function array_key_exists;
20
use function func_get_args;
21
22
final class ExcludedFilesScoper implements PhpScoperScoper
23
{
24
    private readonly array $excludedFilePathsAsKeys;
25
26
    public function __construct(
27
        private readonly PhpScoperScoper $decoratedScoper,
28
        string ...$excludedFilePaths,
29
    ) {
30
        $this->excludedFilePathsAsKeys = array_flip($excludedFilePaths);
0 ignored issues
show
The property excludedFilePathsAsKeys is declared read-only in KevinGH\Box\PhpScoper\ExcludedFilesScoper.
Loading history...
31
    }
32
33
    public function scope(string $filePath, string $contents): string
34
    {
35
        if (array_key_exists($filePath, $this->excludedFilePathsAsKeys)) {
36
            return $contents;
37
        }
38
39
        return $this->decoratedScoper->scope(...func_get_args());
40
    }
41
}
42