Property   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 84
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A name() 0 4 1
A defaultValue() 0 4 1
A type() 0 4 1
A visibility() 0 4 1
A setStatic() 0 4 2
A isStatic() 0 4 1
1
<?php
2
3
namespace Leaditin\Code\Member;
4
5
use Leaditin\Code\Flag;
6
use Leaditin\Code\Type;
7
use Leaditin\Code\Value;
8
use Leaditin\Code\Visibility;
9
10
/**
11
 * @package Leaditin\Code
12
 * @author Igor Vuckovic <[email protected]>
13
 * @license MIT
14
 */
15
class Property
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $name;
21
22
    /**
23
     * @var Type
24
     */
25
    protected $type;
26
27
    /**
28
     * @var Value
29
     */
30
    protected $defaultValue;
31
32
    /**
33
     * @var Flag
34
     */
35
    protected $flag;
36
37
    /**
38
     * @param string $name
39
     * @param Value $defaultValue
40
     * @param Type $type
41
     * @param null|Flag $flag
42
     */
43 6
    public function __construct(string $name, Value $defaultValue, Type $type, Flag $flag = null)
44
    {
45 6
        $this->name = $name;
46 6
        $this->defaultValue = $defaultValue;
47 6
        $this->type = $type;
48 6
        $this->flag = $flag ?? new Flag(Flag::FLAG_PUBLIC);
49 6
    }
50
51
    /**
52
     * @return string
53
     */
54 1
    public function name(): string
55
    {
56 1
        return $this->name;
57
    }
58
59
    /**
60
     * @return Value
61
     */
62 1
    public function defaultValue(): Value
63
    {
64 1
        return $this->defaultValue;
65
    }
66
67
    /**
68
     * @return Type
69
     */
70 1
    public function type(): Type
71
    {
72 1
        return $this->type;
73
    }
74
75
    /**
76
     * @return Visibility
77
     */
78 4
    public function visibility(): Visibility
79
    {
80 4
        return Visibility::fromFlag($this->flag);
81
    }
82
83
    /**
84
     * @param bool $isStatic
85
     */
86 1
    public function setStatic(bool $isStatic): void
87
    {
88 1
        $isStatic ? $this->flag->addFlag(Flag::FLAG_STATIC) : $this->flag->removeFlag(Flag::FLAG_STATIC);
89 1
    }
90
91
    /**
92
     * @return bool
93
     */
94 1
    public function isStatic(): bool
95
    {
96 1
        return $this->flag->hasFlag(Flag::FLAG_STATIC);
97
    }
98
}
99