Test Setup Failed
Push — master ( 1595cb...050b68 )
by Kirill
21:00
created

DescriptionReaderTrait::descriptionOf()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Backend\Context\Support;
13
14
use Railt\SDL\Frontend\Ast\Node;
15
use Railt\TypeSystem\Value\StringValue;
16
17
/**
18
 * Trait DescriptionReaderTrait
19
 */
20
trait DescriptionReaderTrait
21
{
22
    /**
23
     * @param Node $node
24
     * @return string|null
25
     */
26
    protected function descriptionOf(Node $node): ?string
27
    {
28
        if (! \property_exists($node, 'description')) {
29
            return null;
30
        }
31
32
        if ($node->description instanceof StringValue) {
33
            return $node->description->toPHPValue();
34
        }
35
36
        return null;
37
    }
38
}
39