AbstractSelectionFromMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 27
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A provideSelectionsData() 0 3 1
A defineSelectionValue() 0 3 1
A getSelection() 0 3 1
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Selection\Abstracts;
4
5
use WebTheory\Saveyour\Contracts\Field\Selection\SelectionProviderInterface;
6
7
abstract class AbstractSelectionFromMap implements SelectionProviderInterface
8
{
9
    protected array $selection = [];
10
11
    public function __construct(array $selection)
12
    {
13
        $this->selection = $selection;
14
    }
15
16
    /**
17
     * Get the value of selection
18
     *
19
     * @return array
20
     */
21
    public function getSelection(): array
22
    {
23
        return $this->selection;
24
    }
25
26
    public function provideSelectionsData(): array
27
    {
28
        return $this->selection;
29
    }
30
31
    public function defineSelectionValue($item): string
32
    {
33
        return array_search($item, $this->selection);
34
    }
35
}
36