Completed
Push — master ( 9b99ba...c3f75f )
by Kirill
02:20
created

CodeNode::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
/**
3
 * This file is part of Platform package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Karma\Platform\Ast;
11
12
/**
13
 * Class CodeNode
14
 * @package Karma\Platform\Ast
15
 */
16
class CodeNode extends TextNode
17
{
18
    /**
19
     * Language is not defined
20
     */
21
    protected const LANGUAGE_GENERIC = 'generic';
22
23
    /**
24
     * @var string
25
     */
26
    private $language;
27
28
    /**
29
     * CodeNode constructor.
30
     * @param string $body
31
     * @param null|string $language
32
     */
33
    public function __construct(string $body, ?string $language)
34
    {
35
        $this->language = $language ?: static::LANGUAGE_GENERIC;
36
37
        parent::__construct($body);
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function isGeneric(): bool
44
    {
45
        return $this->language === static::LANGUAGE_GENERIC;
46
    }
47
}
48