Completed
Push — develop ( 67e161...8b0772 )
by Paul
05:50
created

InterfaceNodeParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 1
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParser;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\ClassModel;
7
use PhpUnitGen\Model\InterfaceModel;
8
use PhpUnitGen\Model\ModelInterface\PhpFileModelInterface;
9
use PhpUnitGen\Model\PropertyInterface\NodeInterface;
10
11
/**
12
 * Class InterfaceNodeParser.
13
 *
14
 * @author     Paul Thébaud <[email protected]>.
15
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
16
 * @license    https://opensource.org/licenses/MIT The MIT license.
17
 * @link       https://github.com/paul-thebaud/phpunit-generator
18
 * @since      Class available since Release 2.0.0.
19
 */
20
class InterfaceNodeParser implements NodeParserInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function parse(Node $nodeToParse, NodeInterface $node): NodeInterface
26
    {
27
        /**
28
         * Overriding variable types.
29
         * @var Node\Stmt\Interface_  $nodeToParse The namespace node to parse.
30
         * @var PhpFileModelInterface $node        The node which contains this namespace.
31
         */
32
        $interfaceModel = new InterfaceModel();
33
        $interfaceModel->setName($nodeToParse->name);
0 ignored issues
show
Bug introduced by
It seems like $nodeToParse->name can also be of type null; however, parameter $name of PhpUnitGen\Model\InterfaceModel::setName() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        $interfaceModel->setName(/** @scrutinizer ignore-type */ $nodeToParse->name);
Loading history...
34
        $interfaceModel->setParentNode($node);
35
        $interfaceModel->setPhpFileModel($node);
36
37
        return $interfaceModel;
38
    }
39
}
40