NamespaceReplacement   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A enterNode() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\PhpGenerics\Generator\Visitor;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Name;
7
use PhpParser\Node\Stmt\Namespace_;
8
use PhpParser\NodeVisitorAbstract;
9
10
final class NamespaceReplacement extends NodeVisitorAbstract
11
{
12
    /** @var string */
13
    private $namespace;
14
15
    public function __construct(string $namespace)
16
    {
17
        $this->namespace = $namespace;
18
    }
19
20
    public function enterNode(Node $node)
21
    {
22
        if (!$node instanceof Namespace_) {
23
            return null;
24
        }
25
        return new Namespace_(
26
            new Name($this->namespace),
27
            $node->stmts,
28
            $node->getAttributes()
29
        );
30
    }
31
}
32