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

SlugEvent::getProperty()   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 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