Test Setup Failed
Push — master ( 050b68...43996d )
by Kirill
03:02
created

DefinitionContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
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;
13
14
use Railt\SDL\Frontend\Ast\DefinitionNode;
15
use Railt\SDL\Frontend\Ast\Node;
16
17
/**
18
 * Class DefinitionContext
19
 */
20
abstract class DefinitionContext implements LocalContextInterface
21
{
22
    /**
23
     * @var DefinitionNode
24
     */
25
    protected DefinitionNode $ast;
26
27
    /**
28
     * DefinitionContext constructor.
29
     *
30
     * @param DefinitionNode $ast
31
     */
32
    public function __construct(DefinitionNode $ast)
33
    {
34
        $this->ast = $ast;
35
    }
36
37
    /**
38
     * @param Node $node
39
     * @return string|null
40
     */
41
    protected function description(Node $node): ?string
42
    {
43
        if (\property_exists($node, 'description') && $node->description) {
44
            return $node->description->value;
45
        }
46
47
        return null;
48
    }
49
}
50