Completed
Pull Request — master (#79)
by Svetlozar
24:20 queued 21:06
created

Kohana_Jam_Event_Data   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 51
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stop() 0 4 1
A __construct() 0 7 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 35
	public function __construct($params)
54
	{
55 35
		foreach ($params as $param => $value)
56
		{
57 22
			$this->$param = $value;
58
		}
59 35
	}
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