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

ClassLikeNameHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getName() 0 6 2
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