Passed
Push — develop ( f3d119...d95d5b )
by Paul
02:17
created

ClassLikeNameHelper::getName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParserUtil;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\PropertyInterface\NameInterface;
7
8
/**
9
 * Class ClassLikeNameHelper.
10
 *
11
 * @author     Paul Thébaud <[email protected]>.
12
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
13
 * @license    https://opensource.org/licenses/MIT The MIT license.
14
 * @link       https://github.com/paul-thebaud/phpunit-generator
15
 * @since      Class available since Release 2.0.0.
16
 */
17
class ClassLikeNameHelper
18
{
19
    /**
20
     * Get the name of a node.
21
     *
22
     * @param Node\Stmt\ClassLike $node The node.
23
     *
24
     * @return string The found name.
25
     */
26
    public static function getName(Node\Stmt\ClassLike $node): string
27
    {
28
        if ($node->name === null) {
29
            return NameInterface::UNKNOWN_NAME;
30
        }
31
        return $node->name;
32
    }
33
}
34