EventArguments::createEmpty()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace As3\Modlr\Events;
4
5
/**
6
 * Contains the arguments for an event.
7
 * This is the root class and does not contain any event data.
8
 * All event arguments must extend this class and define their own state.
9
 *
10
 * @author Jacob Bare <[email protected]>
11
 */
12
class EventArguments
13
{
14
    /**
15
     * The globally empty event instance.
16
     * Used when no event arguments are passed to the dispatcher.
17
     *
18
     * @var self
19
     */
20
    private static $emptyInstance;
21
22
    /**
23
     * Creates an empty arguments instance.
24
     * Ensures only one empty instances exists for all possible event calls without arguments.
25
     *
26
     * @return  self
27
     */
28
    public static function createEmpty()
29
    {
30
        if (null === self::$emptyInstance) {
31
            self::$emptyInstance = new self;
32
        }
33
        return self::$emptyInstance;
34
    }
35
}
36