Completed
Push — develop ( 763ea8...df26dc )
by Paul
01:58
created

MethodNodeParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParser;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\FunctionModel;
7
use PhpUnitGen\Model\PropertyInterface\ClassLikeInterface;
8
use PhpUnitGen\Model\PropertyInterface\NodeInterface;
9
10
/**
11
 * Class MethodNodeParser.
12
 *
13
 * @author     Paul Thébaud <[email protected]>.
14
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
15
 * @license    https://opensource.org/licenses/MIT The MIT license.
16
 * @link       https://github.com/paul-thebaud/phpunit-generator
17
 * @since      Class available since Release 2.0.0.
18
 */
19
class MethodNodeParser extends AbstractNodeParser
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function parse(Node $node, NodeInterface $parent): NodeInterface
25
    {
26
        /**
27
         * Overriding variable types.
28
         * @var Node\Stmt\ClassMethod $node   The method node to parse.
29
         * @var ClassLikeInterface    $parent The node which contains this namespace.
30
         */
31
        $function = new FunctionModel();
32
        $function->setName($node->name);
33
34
        $parent->addFunction($function);
35
36
        return $parent;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $parent returns the type PhpUnitGen\Model\Propert...face\ClassLikeInterface which is incompatible with the type-hinted return PhpUnitGen\Model\PropertyInterface\NodeInterface.
Loading history...
37
    }
38
}
39