Passed
Push — master ( 3c0766...793f0f )
by Chris
05:28
created

AbstractSelectionProvider::getSelection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 6
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Fields\Selections;
4
5
use WebTheory\Saveyour\Contracts\SelectionProviderInterface;
6
7
abstract class AbstractSelectionProvider implements SelectionProviderInterface
8
{
9
    /**
10
     *
11
     */
12
    public function getSelection(): array
13
    {
14
        $selection = [];
15
16
        foreach ($this->provideItemsAsRawData() as $item) {
17
            $selection[$this->provideItemKey($item)] = $this->provideItem($item);
18
        }
19
20
        return $selection;
21
    }
22
23
    /**
24
     *
25
     */
26
    abstract protected function provideItemsAsRawData(): array;
27
28
    /**
29
     *
30
     */
31
    abstract protected function provideItemKey($item): string;
32
33
    /**
34
     * @var mixed
35
     */
36
    abstract protected function provideItem($item);
37
}
38