Completed
Push — master ( ac62eb...633109 )
by Dawid
03:39
created

Enum::extract()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
crap 2
1
<?php declare(strict_types=1);
2
3
namespace Igni\Storage\Mapping\Strategy;
4
5
use Igni\Storage\Mapping\MappingStrategy;
6
7
final class Enum implements MappingStrategy, DefaultAttributesProvider
8
{
9 2
    public static function hydrate(&$value, array $attributes = []): void
10
    {
11 2
        $value = $attributes['values'][$value];
12 2
    }
13
14
    public static function extract(&$value, array $attributes = []): void
15
    {
16
        $value = array_search($value, $attributes['values']);
17
    }
18
19 1
    public static function getDefaultAttributes(): array
20
    {
21
        return [
22 1
            'values' => [],
23
        ];
24
    }
25
}
26