RuntimeProperty::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Igni\Utils\ReflectionApi;
4
5
class RuntimeProperty implements CodeGenerator
6
{
7
    use VisibilityTrait;
8
    use DefaultValueTrait;
9
    use StaticTrait;
10
11
    private $name;
12
13 3
    public function __construct(string $name)
14
    {
15 3
        $this->name = $name;
16 3
    }
17
18 2
    public function getName(): string
19
    {
20 2
        return $this->name;
21
    }
22
23 2
    public function generateCode(): string
24
    {
25 2
        $code = $this->visibility;
26
27 2
        if ($this->isStatic()) {
28 1
            $code .= ' static';
29
        }
30
31 2
        $code .= ' $' . $this->name;
32
33 2
        if ($this->hasDefaultValue()) {
34
            $code .= ' = ' . var_export($this->defaultValue, true);
35
        }
36
37 2
        return $code . ';';
38
    }
39
}
40