Passed
Push — master ( 3491f1...e1ceb1 )
by Chris
40:32
created

KernelPoweredCollectionTrait   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 53
ccs 0
cts 21
cp 0
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A expose() 0 5 1
A spawn() 0 7 1
A toArray() 0 3 1
A count() 0 3 1
A getIterator() 0 3 1
A hasItems() 0 3 1
A toJson() 0 3 1
A values() 0 3 1
A jsonSerialize() 0 3 1
1
<?php
2
3
namespace Leonidas\Library\Core\Abstracts;
4
5
use Leonidas\Contracts\Collection\ObjectCollectionInterface;
6
use Traversable;
7
use WebTheory\Collection\Contracts\CollectionKernelInterface;
8
9
trait KernelPoweredCollectionTrait
10
{
11
    protected CollectionKernelInterface $kernel;
12
13
    public function hasItems(): bool
14
    {
15
        return $this->kernel->hasItems();
16
    }
17
18
    public function count(): int
19
    {
20
        return $this->kernel->count();
21
    }
22
23
    public function values(): array
24
    {
25
        return $this->kernel->values();
26
    }
27
28
    public function toArray(): array
29
    {
30
        return $this->kernel->toArray();
31
    }
32
33
    public function toJson(): string
34
    {
35
        return $this->kernel->toJson();
36
    }
37
38
    public function getIterator(): Traversable
39
    {
40
        return $this->kernel;
41
    }
42
43
    public function jsonSerialize(): array
44
    {
45
        return $this->kernel->jsonSerialize();
46
    }
47
48
    protected function spawn(CollectionKernelInterface $kernel): ObjectCollectionInterface
49
    {
50
        $spawn = clone $this;
51
52
        $spawn->kernel = $kernel;
53
54
        return $spawn;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $spawn returns the type Leonidas\Library\Core\Ab...lPoweredCollectionTrait which is incompatible with the type-hinted return Leonidas\Contracts\Colle...jectCollectionInterface.
Loading history...
55
    }
56
57
    protected function expose(ObjectCollectionInterface ...$collections): array
58
    {
59
        return array_map(
60
            fn (ObjectCollectionInterface $collection) => $collection->toArray(),
61
            $collections
62
        );
63
    }
64
}
65