EnumCastable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
__construct() 0 1 ?
getValue() 0 1 ?
A get() 0 4 1
A set() 0 8 2
1
<?php
2
3
namespace MadWeb\Enum;
4
5
/**
6
 * @mixin \MadWeb\Enum\Enum
7 12
 * @internal Uses for custom casting implementation
8
 */
9 12
trait EnumCastable
10
{
11 12
    abstract public function __construct($value = null);
12 9
13
    abstract public function getValue();
14 9
15 9
    public function get($model, string $key, $value, array $attributes)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    {
17
        return new static($value);
18
    }
19 12
20
    public function set($model, string $key, $value, array $attributes)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
    {
22
        if ($value instanceof static) {
23
            return $value->getValue();
24
        }
25
26
        return (new static($value))->getValue();
27
    }
28
}
29