CodeNode::isGeneric()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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