SlugEvent::getEntity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event;
6
7
/**
8
 * @author Alexis BUSSIERES <[email protected]>
9
 *
10
 * The SlugEvent class is used for an entity which have a slug
11
 * shared between different entities.
12
 */
13
class SlugEvent extends Event
14
{
15
    private $entity;
16
    private $property;
17
18
    /**
19
     * SlugEvent constructor.
20
     *
21
     * @param $entity object
22
     * @param $property string
23
     */
24
    public function __construct($entity, $property)
25
    {
26 View Code Duplication
        if (!is_object($entity)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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