Passed
Pull Request — master (#8)
by Alex
03:52
created

CollectionEvent::setCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\DoctrineEntityRepository\Persistence\Event;
6
7
use Arp\Entity\EntityInterface;
8
9
/**
10
 * @author  Alex Patterson <[email protected]>
11
 * @package Arp\DoctrineEntityRepository\Persistence\Event
12
 */
13
class CollectionEvent extends AbstractEntityEvent
14
{
15
    /**
16
     * @var iterable<EntityInterface>
17
     */
18
    private iterable $collection = [];
19
20
    /**
21
     * @return int
22
     */
23 2
    public function getCount(): int
24
    {
25 2
        $collection = ($this->collection instanceof \Traversable)
26 1
            ? iterator_to_array($this->collection)
27 2
            : $this->collection;
28
29 2
        return count($collection);
30
    }
31
32
    /**
33
     * @return iterable<EntityInterface>
34
     */
35 2
    public function getCollection(): iterable
36
    {
37 2
        return $this->collection;
38
    }
39
40
    /**
41
     * @param iterable<EntityInterface> $collection
42
     */
43 4
    public function setCollection(iterable $collection): void
44
    {
45 4
        $this->collection = $collection;
46 4
    }
47
}
48