Event::setSubject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Knp\RadBundle\DomainEvent;
4
5
use Symfony\Component\EventDispatcher\Event as BaseEvent;
6
7
class Event extends BaseEvent
8
{
9
    private $eventName;
10
    private $properties;
11
    private $subject;
12
13
    public function __construct($eventName, array $properties = array())
14
    {
15
        $this->eventName = $eventName;
16
        $this->properties = $properties;
17
    }
18
19
    public function getName()
20
    {
21
        return $this->eventName;
22
    }
23
24
    public function __get($name)
25
    {
26
        if (!array_key_exists($name, $this->properties)) {
27
            throw new \RuntimeException("Property '$name' does not exist on event '{$this->eventName}'");
28
        }
29
30
        return $this->properties[$name];
31
    }
32
33
    public function setSubject(Provider $subject)
34
    {
35
        $this->subject = $subject;
36
    }
37
38
    public function getSubject()
39
    {
40
        return $this->subject;
41
    }
42
}
43