RuntimeProperty   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 35
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A generateCode() 0 16 3
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