Completed
Push — master ( dcddf7...d2fb4d )
by Théo
05:16 queued 03:22
created

CollectUseStmtNodeVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A enterNode() 0 8 2
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\NodeVisitor\UseStmt;
16
17
use Humbug\PhpScoper\NodeVisitor\UseStmtCollection;
18
use PhpParser\Node;
19
use PhpParser\Node\Stmt\Use_;
20
use PhpParser\NodeVisitorAbstract;
21
22
final class CollectUseStmtNodeVisitor extends NodeVisitorAbstract
23
{
24
    private $useStatements;
25
26
    public function __construct(UseStmtCollection $useStatements)
27
    {
28
        $this->useStatements = $useStatements;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function enterNode(Node $node): Node
35
    {
36
        if ($node instanceof Use_) {
37
            $this->useStatements->add($node);
38
        }
39
40
        return $node;
41
    }
42
}
43