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

CodeNode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A isGeneric() 0 4 1
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