Completed
Push — master ( 024186...18bea3 )
by Peter
06:06
created

NameResolverContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A changeResolver() 0 4 1
A getResolver() 0 8 2
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Domain\Event\NameResolver;
11
12
/**
13
 * It's a global container for get event name resolver in entities.
14
 *
15
 * It's need for not duplicate code
16
 *
17
 * @see AggregateEventsRaiseInSelfTrait::getMethodNameFromEvent()
18
 * @see SwitchListenerTrait::getMethodNameFromEvent()
19
 */
20
class NameResolverContainer
21
{
22
    /**
23
     * @var EventNameResolverInterface
24
     */
25
    private static $resolver;
26
27
    /**
28
     * @param EventNameResolverInterface $resolver
29
     */
30 1
    public static function changeResolver(EventNameResolverInterface $resolver)
31
    {
32 1
        self::$resolver = $resolver;
33 1
    }
34
35
    /**
36
     * @return EventNameResolverInterface
37
     */
38 5
    public static function getResolver()
39
    {
40 5
        if (!(self::$resolver instanceof EventNameResolverInterface)) {
41 1
            self::$resolver = new EventClassLastPartResolver(); // default name resolver
42 1
        }
43
44 5
        return self::$resolver;
45
    }
46
}
47