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

CollectionCrudEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getEntities() 0 4 1
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