Event::getSubject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
c 2
b 2
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PEIP\Event;
4
5
namespace PEIP\Event;
6
7
/*
8
 * This file is part of the PEIP package.
9
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
/*
16
 * Event
17
 *
18
 * @author Timo Michna <timomichna/yahoo.de>
19
 * @package PEIP
20
 * @subpackage event
21
 * @extends \PEIP\Message\GenericMessage
22
 * @implements \PEIP\INF\Base\Buildable, \PEIP\INF\Message\Message, \PEIP\INF\Base\Container, \PEIP\INF\Event\Event
23
 */
24
25
26
27
28
use PEIP\Util\Test;
29
30
class Event extends \PEIP\Message\GenericMessage implements
31
        \PEIP\INF\Event\Event
32
{
33
    protected $value = null,
34
        $processed = false,
35
        $subject = null,
36
        $name = '',
37
        $parameters = null,
38
        $type;
39
40
    /**
41
     * constructor.
42
     *
43
     * @param mixed  $subject the subject for the event
44
     * @param string $name    the name of the event
45
     */
46
    public function __construct($subject, $name, $parameters = [], $type = false)
47
    {
48
        parent::__construct($subject, Test::ensureArrayAccess($parameters));
49
        $this->name = $name;
50
        $this->type = $type ? $type : get_class($this);
51
    }
52
53
    /**
54
     * returns the name of the event.
55
     *
56
     * @return string the name of the event
57
     */
58
    public function getName()
59
    {
60
        return $this->name;
61
    }
62
63
    /**
64
     * returns the type of the event (Name of this Event-Class if no
65
     * event-type has been set in constructor).
66
     *
67
     * @return string the type of the event
68
     */
69
    public function getType()
70
    {
71
        return $this->name;
72
    }
73
74
    /**
75
     * sets the return-value of the event.
76
     *
77
     * @param mixed $value the return-value to set
78
     */
79
    public function setReturnValue($value)
80
    {
81
        $this->value = $value;
82
    }
83
84
    /**
85
     * returns the return-value of the event.
86
     *
87
     * @return mixed the return-value to set
88
     */
89
    public function getReturnValue()
90
    {
91
        return $this->value;
92
    }
93
94
    /**
95
     * sets wether the event is processed.
96
     *
97
     * @param bool $processed
98
     */
99
    public function setProcessed($processed)
100
    {
101
        $this->processed = (bool) $processed;
102
    }
103
104
    /**
105
     * checks wether the event is processed.
106
     *
107
     * @return bool wether the event is processed
108
     */
109
    public function isProcessed()
110
    {
111
        return $this->processed;
112
    }
113
114
    /**
115
     * Returns the subject/content of the container.
116
     *
117
     * @return mixed the subject/content
118
     */
119
    public function getSubject()
120
    {
121
        return $this->getContent();
122
    }
123
}
124