Completed
Push — master ( e41e91...2b4213 )
by Aleh
01:47 queued 01:39
created

AbstractScope::addVar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Padawan\Domain\Scope;
4
5
use Padawan\Domain\Scope;
6
use Padawan\Domain\Project\FQCN;
7
use Padawan\Domain\Project\Node\Uses;
8
use Padawan\Domain\Project\Node\Variable;
9
use Padawan\Domain\Project\Node\FunctionData;
10
11
abstract class AbstractScope implements Scope
12
{
13
    private $variables = [];
14
    private $functions = [];
15
    private $constants = [];
16
    /** @var Scope */
17
    private $parent;
0 ignored issues
show
Unused Code introduced by
The property $parent is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
18
19
    /** @return Variable[] */
20
    public function getVars()
21
    {
22
        return $this->variables;
23
    }
24
25
    /** @return Variable */
26
    public function getVar($varName)
27
    {
28
        if (array_key_exists($varName, $this->variables)) {
29
            return $this->variables[$varName];
30
        }
31
    }
32
33
    public function addVar(Variable $var)
34
    {
35
        $this->variables[$var->getName()] = $var;
36
    }
37
38
    public function getFunctions()
39
    {
40
        return $this->functions;
41
    }
42
43
    public function getFunction($functionName)
44
    {
45
        if (array_key_exists($functionName, $this->functions)) {
46
            return $this->functions[$functionName];
47
        }
48
    }
49
50
    public function addFunction(FunctionData $function)
51
    {
52
        $this->functions[$function->name] = $function;
53
    }
54
55
    /** @return string[] */
56
    public function getConstants()
57
    {
58
        return $this->constants;
59
    }
60
61
    public function getConstant($constName)
62
    {
63
        if (array_key_exists($constName, $this->constants)) {
64
            return $this->constants[$constName];
65
        }
66
    }
67
68
    public function addConstant($constName)
69
    {
70
        $this->constants[$constName] = $constName;
71
    }
72
}
73