Passed
Push — develop ( fb709e...b69568 )
by Paul
03:14
created

UseNodeParser::parse()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 17
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 3
nop 2
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParser;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\ModelInterface\PhpFileModelInterface;
7
use PhpUnitGen\Parser\NodeParser\NodeParserInterface\UseNodeParserInterface;
8
9
/**
10
 * Class UseNodeParser.
11
 *
12
 * @author     Paul Thébaud <[email protected]>.
13
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
14
 * @license    https://opensource.org/licenses/MIT The MIT license.
15
 * @link       https://github.com/paul-thebaud/phpunit-generator
16
 * @since      Class available since Release 2.0.0.
17
 */
18
class UseNodeParser extends AbstractNodeParser implements UseNodeParserInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function invoke(Node\Stmt\Use_ $node, PhpFileModelInterface $parent): PhpFileModelInterface
24
    {
25
        foreach ($node->uses as $use) {
26
            $parent->addUse($use->alias, $use->name->toString());
27
        }
28
29
        return $parent;
30
    }
31
}
32