Completed
Push — master ( 84afd6...650043 )
by Evstati
14s
created

Kohana_Jam_Event_Data::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
/**
3
 * Jam Event Data is the object passed to all events
4
 *
5
 * It contains a set of public properties passed to it
6
 * whoever triggered the event as well as the name of
7
 * the event being called.
8
 *
9
 * Set `return` to whatever value you'd like to return,
10
 * though you should keep in mind that other events,
11
 * that come after may modify that value, so set
12
 * `stop` to TRUE if you want to prevent the chain from
13
 * continuing.
14
 *
15
 * @package    Jam
16
 * @category   Events
17
 * @author     Jonathan Geiger
18
 * @copyright  (c) 2010-2011 Jonathan Geiger
19
 * @license    http://www.opensource.org/licenses/isc-license.txt
20
 */
21
abstract class Kohana_Jam_Event_Data {
22
23
	/**
24
	 * @var  string  The name of the event
25
	 */
26
	public $event = NULL;
27
28
	/**
29
	 * @var  mixed  The sender of the event
30
	 */
31
	public $sender = NULL;
32
33
	/**
34
	 * @var  args  An array of args sent to the event
35
	 */
36
	public $args = array();
37
38
	/**
39
	 * @var  mixed  The return value of the event
40
	 */
41
	public $return = NULL;
42
43
	/**
44
	 * @var  boolean  Whether or not to stop execution of events
45
	 */
46
	public $stop = FALSE;
47
48
	/**
49
	 * Throws all event parameters into the object as public variables
50
	 *
51
	 * @param  array  $params
52
	 */
53 80
	public function __construct($params)
54
	{
55 80
		foreach ($params as $param => $value)
56
		{
57 67
			$this->$param = $value;
58
		}
59 80
	}
60
61
	/**
62
	 * Stops execution of the event
63
	 *
64
	 * @return void
65
	 */
66
	public function stop()
67
	{
68
		$this->stop = TRUE;
69
	}
70
71
} // End Kohana_Jam_Event_Data
72