Passed
Pull Request — master (#302)
by Théo
02:32
created

SimpleScoper::changeWhitelist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 as PhpScoper;
18
use Humbug\PhpScoper\Whitelist;
19
20
/**
21
 * @private
22
 */
23
final class SimpleScoper implements Scoper
24
{
25
    private $scoper;
26
    private $prefix;
27
    private $whitelist;
28
    private $patchers;
29
30
    public function __construct(PhpScoper $scoper, string $prefix, Whitelist $whitelist, array $patchers)
31
    {
32
        $this->scoper = $scoper;
33
        $this->prefix = $prefix;
34
        $this->whitelist = $whitelist;
35
        $this->patchers = $patchers;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function scope(string $filePath, string $contents): string
42
    {
43
        return $this->scoper->scope(
44
            $filePath,
45
            $contents,
46
            $this->prefix,
47
            $this->patchers,
48
            $this->whitelist
49
        );
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function changeWhitelist(Whitelist $whitelist): void
56
    {
57
        $this->whitelist = $whitelist;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getWhitelist(): Whitelist
64
    {
65
        return $this->whitelist;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getPrefix(): string
72
    {
73
        return $this->prefix;
74
    }
75
}
76