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

CollectionEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCount() 0 7 2
A setCollection() 0 3 1
A getCollection() 0 3 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