Completed
Push — master ( 589f5d...2e0cd6 )
by Pavel
07:02
created

CollectionCrudEvent::getEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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 array $entities
17
     */
18
    public function __construct($entities)
19
    {
20
        if ($entities instanceof Collection) {
21
            $this->entities = $entities;
22
        } elseif (is_array($entities)) {
23
            $this->entities = new ArrayCollection($entities);
24
        } else {
25
            $this->entities = new ArrayCollection([$entities]);
26
        }
27
    }
28
29
    /**
30
     * @return Collection
31
     */
32
    public function getEntities()
33
    {
34
        return $this->entities;
35
    }
36
}
37