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

KernelPoweredCollectionTrait::hasItems()   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 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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