Passed
Push — master ( 2a3624...3abe14 )
by Théo
03:10
created

FullyQualifiedNamespaceUseScoperNodeVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
namespace Humbug\PhpScoper\NodeVisitor;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Name;
7
use PhpParser\Node\Name\FullyQualified;
8
use PhpParser\NodeVisitorAbstract;
9
10
final class FullyQualifiedNamespaceUseScoperNodeVisitor extends NodeVisitorAbstract
11
{
12
    /**
13
     * @var string
14
     */
15
    private $prefix;
16
17
    public function __construct($prefix)
18
    {
19
        $this->prefix = $prefix;
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function enterNode(Node $node)
26
    {
27
        if ($node instanceof FullyQualified) {
28
            return new Name(Name::concat($this->prefix, (string) $node));
29
        }
30
31
        return $node;
32
    }
33
}
34