Completed
Push — master ( c1861a...00813f )
by Benjamin
06:00 queued 02:48
created

SlugEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 4
A getEntity() 0 4 1
A getProperty() 0 4 1
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event;
6
7
8
/**
9
 * @author Alexis BUSSIERES <[email protected]>
10
 *
11
 * The SlugEvent class is used for an entity which have a slug
12
 * shared between different entities.
13
 */
14
class SlugEvent extends Event
15
{
16
    private $entity;
17
    private $property;
18
19
    /**
20
     * SlugEvent constructor.
21
     * @param $entity object
22
     * @param $property string
23
     */
24
    public function __construct($entity, $property)
25
    {
26
        if (!is_object($entity)) {
27
            throw new \InvalidArgumentException('The "$entity" parameter must be an object.');
28
        } elseif (!empty($property) && is_string($property)) {
29
            throw new \InvalidArgumentException('The "$property" parameter must be a non empty string.');
30
        }
31
32
        $this->entity = $entity;
33
        $this->property = $property;
34
    }
35
36
    /**
37
     * @return object
38
     */
39
    public function getEntity()
40
    {
41
        return $this->entity;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getProperty()
48
    {
49
        return $this->property;
50
    }
51
}
52