Passed
Push — master ( 2f6942...d6d802 )
by Chris
28:11
created

FusionSelection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 7
eloc 11
dl 0
loc 44
ccs 9
cts 15
cp 0.6
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 3 1
A insert() 0 3 1
A remix() 0 3 1
A contains() 0 3 1
A fetch() 0 3 1
A remove() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace WebTheory\Collection\Fusion\Collection;
4
5
use WebTheory\Collection\Access\StandardMap;
6
use WebTheory\Collection\Comparison\ObjectComparator;
7
use WebTheory\Collection\Contracts\ArrayDriverInterface;
8
use WebTheory\Collection\Contracts\ArrayFusionInterface;
9
10
class FusionSelection
11
{
12
    /**
13
     * @var array<string,ArrayFusionInterface>
14
     */
15
    protected array $fusions = [];
16
17
    protected ArrayDriverInterface $driver;
18
19 309
    public function __construct(array $fusions)
20
    {
21 309
        $this->driver = new StandardMap(new ObjectComparator());
22
23 309
        $this->collect($fusions);
24
    }
25
26 309
    public function collect(array $fusions)
27
    {
28 309
        array_walk($fusions, [$this, 'insert']);
29
    }
30
31 309
    public function insert(ArrayFusionInterface $fusion, string $name): void
32
    {
33 309
        $this->driver->insert($this->fusions, $fusion, $name);
34
    }
35
36
    public function remove(string $fusion): void
37
    {
38
        $this->driver->remove($this->fusions, $fusion);
39
    }
40
41 69
    public function fetch(string $fusion): ArrayFusionInterface
42
    {
43 69
        return $this->driver->fetch($this->fusions, $fusion);
44
    }
45
46
    public function contains(string $fusion): bool
47
    {
48
        return $this->driver->contains($this->fusions, $fusion);
49
    }
50
51
    public function remix(string $fusion, array ...$collections): array
52
    {
53
        return $this->fetch($fusion)->remix(...$collections);
54
    }
55
}
56