Completed
Pull Request — master (#21)
by Pavel
21:56
created

CollectionCrudEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 29
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntities() 0 4 1
A __construct() 0 10 3
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Event;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
8
class CollectionCrudEvent extends CrudEvent
9
{
10
    /** @var Collection */
11
    private $entities = [];
12
13
    /**
14
     * CollectionCrudEvent constructor.
15
     *
16
     * @param object|object[]|Collection $entities
17
     */
18 38
    public function __construct($entities)
19
    {
20 38
        if ($entities instanceof Collection) {
21 6
            $this->entities = $entities;
22 32
        } elseif (is_array($entities)) {
23 32
            $this->entities = new ArrayCollection($entities);
24
        } else {
25
            $this->entities = new ArrayCollection([$entities]);
26
        }
27 38
    }
28
29
    /**
30
     * @return Collection
31
     */
32
    public function getEntities()
33
    {
34
        return $this->entities;
35
    }
36
}
37