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

DocumentationTrait::getDocumentation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
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\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