1 | <?php |
||
11 | class Inji { |
||
12 | |||
13 | /** |
||
14 | * Static storage for core object |
||
15 | * |
||
16 | * @var Inji |
||
17 | */ |
||
18 | public static $inst = null; |
||
19 | |||
20 | /** |
||
21 | * Dynamic events listeners |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $_listeners = []; |
||
26 | |||
27 | /** |
||
28 | * Core config |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | public static $config = []; |
||
33 | |||
34 | /** |
||
35 | * Static storage for anything |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | public static $storage = []; |
||
40 | |||
41 | /** |
||
42 | * Stop executing code if this true after use Inji::$inst->stop() constuction in code |
||
43 | * |
||
44 | * @var boolean |
||
45 | */ |
||
46 | public $exitOnStop = true; |
||
47 | |||
48 | /** |
||
49 | * Add event listener |
||
50 | * |
||
51 | * @param string $eventName |
||
52 | * @param string $listenCode |
||
53 | * @param array|closure $callback |
||
54 | * @param boolean $save |
||
55 | */ |
||
56 | 3 | public function listen($eventName, $listenCode, $callback, $save = false) { |
|
65 | |||
66 | /** |
||
67 | * Throw event |
||
68 | * |
||
69 | * @param string $eventName |
||
70 | * @param mixed $eventObject |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 3 | public function event($eventName, $eventObject = null) { |
|
107 | |||
108 | /** |
||
109 | * Unlisten event |
||
110 | * |
||
111 | * @param string $eventName |
||
112 | * @param string $listenCode |
||
113 | * @param boolean $save |
||
114 | */ |
||
115 | 2 | public function unlisten($eventName, $listenCode, $save = false) { |
|
127 | |||
128 | public function stop() { |
||
134 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.