Completed
Push — develop ( e382f7...b48d9b )
by Paul
02:10
created

FunctionNodeParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A invoke() 0 11 1
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParser;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\FunctionModel;
7
use PhpUnitGen\Model\ModelInterface\PhpFileModelInterface;
8
9
/**
10
 * Class FunctionNodeParser.
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 FunctionNodeParser extends AbstractFunctionNodeParser
19
{
20
    /**
21
     * Parse a node to update the parent node model.
22
     *
23
     * @param Node\Stmt\Function_   $node   The node to parse.
24
     * @param PhpFileModelInterface $parent The parent node.
25
     *
26
     * @return PhpFileModelInterface The updated parent.
27
     */
28
    public function invoke(Node\Stmt\Function_ $node, PhpFileModelInterface $parent): PhpFileModelInterface
29
    {
30
        $function = new FunctionModel();
31
        $function->setParentNode($parent);
32
        $function->setName($node->name);
33
34
        $function = $this->parseFunction($node, $function);
35
36
        $parent->addFunction($function);
37
38
        return $parent;
39
    }
40
}
41