newGenericEventDispatcher()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Onoi\EventDispatcher;
4
5
use Onoi\EventDispatcher\Dispatcher\GenericEventDispatcher;
6
use Onoi\EventDispatcher\Listener\NullEventListener;
7
use Onoi\EventDispatcher\Listener\GenericCallbackEventListener;
8
use Onoi\EventDispatcher\Listener\GenericEventListenerCollection;
9
10
/**
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class EventDispatcherFactory {
17
18
	/**
19
	 * @var EventDispatcherFactory
20
	 */
21
	private static $instance = null;
22
23
	/**
24
	 * @since 1.0
25
	 *
26
	 * @return EventDispatcherFactory
27
	 */
28 1
	public static function getInstance() {
29
30 1
		if ( self::$instance === null ) {
31 1
			self::$instance = new self();
32 1
		}
33
34 1
		return self::$instance;
35
	}
36
37
	/**
38
	 * @since 1.0
39
	 */
40 1
	public static function clear() {
41 1
		self::$instance = null;
42 1
	}
43
44
	/**
45
	 * @since 1.0
46
	 *
47
	 * @return GenericEventDispatcher
48
	 */
49 4
	public function newGenericEventDispatcher() {
50 4
		return new GenericEventDispatcher();
51
	}
52
53
	/**
54
	 * @since 1.0
55
	 *
56
	 * @return DispatchContext
57
	 */
58 1
	public function newDispatchContext() {
59 1
		return new DispatchContext();
60
	}
61
62
	/**
63
	 * @since 1.0
64
	 *
65
	 * @return NullEventListener
66
	 */
67 1
	public function newNullEventListener() {
68 1
		return new NullEventListener();
69
	}
70
71
	/**
72
	 * @since 1.0
73
	 *
74
	 * @return GenericCallbackEventListener
75
	 */
76 1
	public function newGenericCallbackEventListener() {
77 1
		return new GenericCallbackEventListener();
78
	}
79
80
	/**
81
	 * @since 1.0
82
	 *
83
	 * @return GenericEventListenerCollection
84
	 */
85 3
	public function newGenericEventListenerCollection() {
86 3
		return new GenericEventListenerCollection();
87
	}
88
89
}
90