EventArgs   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 5
c 5
b 0
f 0
dl 0
loc 30
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEmptyInstance() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Common;
6
7
/**
8
 * EventArgs is the base class for classes containing event data.
9
 *
10
 * This class contains no event data. It is used by events that do not pass state
11
 * information to an event handler when an event is raised. The single empty EventArgs
12
 * instance can be obtained through {@link getEmptyInstance}.
13
 */
14
class EventArgs
15
{
16
    /**
17
     * Single instance of EventArgs.
18
     *
19
     * @var EventArgs
20
     */
21
    private static $_emptyEventArgsInstance;
22
23
    /**
24
     * Gets the single, empty and immutable EventArgs instance.
25
     *
26
     * This instance will be used when events are dispatched without any parameter,
27
     * like this: EventManager::dispatchEvent('eventname');
28
     *
29
     * The benefit from this is that only one empty instance is instantiated and shared
30
     * (otherwise there would be instances for every dispatched in the abovementioned form).
31
     *
32
     * @link https://msdn.microsoft.com/en-us/library/system.eventargs.aspx
33
     * @see EventManager::dispatchEvent
34
     *
35
     * @return EventArgs
36
     */
37 1
    public static function getEmptyInstance()
38
    {
39 1
        if (! self::$_emptyEventArgsInstance) {
40 1
            self::$_emptyEventArgsInstance = new EventArgs();
41
        }
42
43 1
        return self::$_emptyEventArgsInstance;
44
    }
45
}
46