Completed
Push — master ( 430ebb...3c20a3 )
by Peter
02:58
created

NamedEventResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEventName() 0 12 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
namespace GpsLab\Domain\Event\NameResolver;
10
11
use GpsLab\Domain\Event\EventInterface;
12
use GpsLab\Domain\Event\Exception\InvalidEventException;
13
use GpsLab\Domain\Event\NamedEventInterface;
14
15
class NamedEventResolver implements EventNameResolverInterface
16
{
17
    /**
18
     * @param EventInterface $event
19
     *
20
     * @return string
21
     */
22 2
    public function getEventName(EventInterface $event)
23
    {
24 2
        if (!($event instanceof NamedEventInterface)) {
25 1
            throw new InvalidEventException(sprintf(
26 1
                'Event "%s" must be instance of "%s".',
27
                get_class($event),
28 1
                NamedEventInterface::class
29
            ));
30
        }
31
32 1
        return $event->getName();
33
    }
34
}
35