Test Failed
Push — master ( 3b7232...dbe410 )
by Kirill
02:20
created

EnumValueDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A getValue() 0 4 1
A withValue() 0 6 1
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Definition\Dependent;
11
12
use Railt\Reflection\Contracts\Definition\Dependent\EnumValueDefinition as EnumValueDefinitionInterface;
13
use Railt\Reflection\Contracts\Type as TypeInterface;
14
use Railt\Reflection\Type;
15
16
/**
17
 * Class EnumValueDefinition
18
 */
19
class EnumValueDefinition extends AbstractDependentTypeDefinition implements EnumValueDefinitionInterface
20
{
21
    /**
22
     * @var string|null
23
     */
24
    protected $value;
25
26
    /**
27
     * @return TypeInterface
28
     */
29
    public static function getType(): TypeInterface
30
    {
31
        return Type::of(Type::ENUM_VALUE);
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getValue(): string
38
    {
39
        return $this->value ?? $this->getName();
40
    }
41
42
    /**
43
     * @param null|string $value
44
     * @return EnumValueDefinitionInterface|$this
45
     */
46
    public function withValue(?string $value): EnumValueDefinitionInterface
47
    {
48
        $this->value = $value;
49
50
        return $this;
51
    }
52
}
53