ClassLikeNameHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
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
/**
4
 * This file is part of PhpUnitGen.
5
 *
6
 * (c) 2017-2018 Paul Thébaud <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpUnitGen\Parser\NodeParserUtil;
13
14
use PhpParser\Node;
15
use PhpUnitGen\Model\PropertyInterface\NameInterface;
16
17
/**
18
 * Class ClassLikeNameHelper.
19
 *
20
 * @author     Paul Thébaud <[email protected]>.
21
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
22
 * @license    https://opensource.org/licenses/MIT The MIT license.
23
 * @link       https://github.com/paul-thebaud/phpunit-generator
24
 * @since      Class available since Release 2.0.0.
25
 */
26
class ClassLikeNameHelper
27
{
28
    /**
29
     * Get the name of a node.
30
     *
31
     * @param Node\Stmt\ClassLike $node The node.
32
     *
33
     * @return string The found name.
34
     */
35
    public static function getName(Node\Stmt\ClassLike $node): string
36
    {
37
        if ($node->name === null) {
38
            return NameInterface::UNKNOWN_NAME;
39
        }
40
        return $node->name;
41
    }
42
}
43