Passed
Push — master ( 49e31d...c437ac )
by Alexander
13:30 queued 11:42
created

CachedCollection::isCollected()   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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\DataReader\Cache;
6
7
final class CachedCollection
8
{
9
    private ?iterable $collection = null;
10
11
    public function setCollection(iterable $collection): void
12
    {
13
        $this->collection = $collection;
14
    }
15
16
    public function isCollected(): bool
17
    {
18
        return $this->collection !== null;
19
    }
20
21
    public function getCollection(): ?iterable
22
    {
23
        return $this->collection;
24
    }
25
26
    public function getGenerator(): \Generator
27
    {
28
        if ($this->collection !== null) {
29
            yield from $this->collection;
30
        }
31
    }
32
}
33