Passed
Push — master ( 6704cb...7d5ecd )
by Théo
03:14 queued 01:01
created

EvalPrefixer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enterNode() 0 9 3
A __construct() 0 3 1
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\PhpParser\NodeVisitor;
16
17
use Humbug\PhpScoper\PhpParser\StringNodePrefixer;
18
use PhpParser\Node;
19
use PhpParser\Node\Expr\Eval_;
20
use PhpParser\Node\Scalar\String_;
21
use PhpParser\NodeVisitorAbstract;
22
23
final class EvalPrefixer extends NodeVisitorAbstract
24
{
25
    private StringNodePrefixer $stringPrefixer;
26
27
    public function __construct(StringNodePrefixer $stringPrefixer)
28
    {
29
        $this->stringPrefixer = $stringPrefixer;
30 548
    }
31
32 548
    public function enterNode(Node $node): Node
33 6
    {
34
        if ($node instanceof String_
35
            && ParentNodeAppender::findParent($node) instanceof Eval_
36 548
        ) {
37
            $this->stringPrefixer->prefixStringValue($node);
38
        }
39
40
        return $node;
41
    }
42
}
43