Passed
Push — develop ( fb709e...b69568 )
by Paul
03:14
created

DocumentationTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDocumentation() 0 7 2
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParserUtil;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\PropertyInterface\VisibilityInterface;
7
8
/**
9
 * Trait DocumentationTrait.
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
trait DocumentationTrait
18
{
19
    /**
20
     * Get the documentation of a node.
21
     *
22
     * @param Node $node The node.
23
     *
24
     * @return string|null The documentation of the node, null if none.
25
     */
26
    protected function getDocumentation(Node $node): ?string
27
    {
28
        $phpdoc = $node->getDocComment();
29
        if ($phpdoc !== null) {
30
            return $phpdoc->getText();
31
        }
32
        return null;
33
    }
34
}
35