Passed
Push — master ( 5e9dce...cb103f )
by Aleksei
02:54
created

CachedCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollection() 0 3 1
A setCollection() 0 3 1
A isCollected() 0 3 1
A getGenerator() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Data\Reader\Cache;
6
7
final class CachedCollection
8
{
9
    private ?iterable $collection = null;
10
11 12
    public function setCollection(iterable $collection): void
12
    {
13 12
        $this->collection = $collection;
14
    }
15
16 1
    public function isCollected(): bool
17
    {
18 1
        return $this->collection !== null;
19
    }
20
21
    /**
22
     * @psalm-ignore-nullable-return
23
     */
24 10
    public function getCollection(): ?iterable
25
    {
26 10
        return $this->collection;
27
    }
28
29 1
    public function getGenerator(): \Generator
30
    {
31 1
        if ($this->collection !== null) {
32 1
            yield from $this->collection;
33
        }
34
    }
35
}
36