TableEntryASTNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
nc 1
cc 1
eloc 3
nop 2
crap 1
1
<?php
2
3
namespace Vlaswinkel\Lua\AST;
4
5
/**
6
 * Class TableEntryASTNode
7
 *
8
 * @author  Koen Vlaswinkel <[email protected]>
9
 * @package Vlaswinkel\Lua\AST
10
 */
11
class TableEntryASTNode extends ASTNode {
12
    const NAME = 'table_entry';
13
14
    /**
15
     * @var ASTNode|null
16
     */
17
    private $key;
18
    /**
19
     * @var ASTNode
20
     */
21
    private $value;
22
23
    /**
24
     * TableEntryASTNode constructor.
25
     *
26
     * @param null|ASTNode $key
27
     * @param ASTNode      $value
28
     */
29 12
    public function __construct(ASTNode $value, ASTNode $key = null) {
30 12
        $this->value = $value;
31 12
        $this->key   = $key;
32 12
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getName() {
38
        return self::NAME;
39
    }
40
41
    /**
42
     * @return null|ASTNode
43
     */
44 7
    public function getKey() {
45 7
        return $this->key;
46
    }
47
48
    /**
49
     * @return ASTNode
50
     */
51 7
    public function getValue() {
52 7
        return $this->value;
53
    }
54
55
    /**
56
     * @return bool
57
     */
58 7
    public function hasKey() {
59 7
        return $this->key !== null;
60
    }
61
}