Code Duplication    Length = 26-27 lines in 2 locations

src/NodeVisitor/NamespaceScoperNodeVisitor.php 1 location

@@ 10-36 (lines=27) @@
7
use PhpParser\Node\Stmt\Namespace_;
8
use PhpParser\NodeVisitorAbstract;
9
10
final class NamespaceScoperNodeVisitor 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 Namespace_
28
            && null !== $node->name
29
            && $this->prefix !== $node->name->getFirst()
30
        ) {
31
            $node->name = Name::concat($this->prefix, $node->name);
32
        }
33
34
        return $node;
35
    }
36
}
37

src/NodeVisitor/GroupUseNamespaceScoperNodeVisitor.php 1 location

@@ 10-35 (lines=26) @@
7
use PhpParser\Node\Stmt\GroupUse;
8
use PhpParser\NodeVisitorAbstract;
9
10
final class GroupUseNamespaceScoperNodeVisitor 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 GroupUse
28
            && $this->prefix !== $node->prefix->getFirst()
29
        ) {
30
            $node->prefix = Name::concat($this->prefix, $node->prefix);
31
        }
32
33
        return $node;
34
    }
35
}
36