EventDispatcherAwareTrait::getEventDispatcher()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
/*
3
 * This file is part of the Backup package, an RunOpenCode project.
4
 *
5
 * (c) 2015 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * This project is fork of "kbond/php-backup", for full credits info, please
11
 * view CREDITS file that was distributed with this source code.
12
 */
13
namespace RunOpenCode\Backup\Event;
14
15
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16
17
/**
18
 * Class EventDispatcherAwareTrait
19
 *
20
 * Implementation of \RunOpenCode\Backup\Contract\EventDispatcherAwareInterface.
21
 *
22
 * @package RunOpenCode\Backup\Event
23
 */
24
trait EventDispatcherAwareTrait
25
{
26
    /**
27
     * @var EventDispatcherInterface
28
     */
29
    private $eventDispatcher;
30
31
    /**
32
     * Set event dispatcher.
33
     *
34
     * @param EventDispatcherInterface $dispatcher
35
     * @return $this
36
     */
37 42
    public function setEventDispatcher(EventDispatcherInterface $dispatcher)
38
    {
39 42
        $this->eventDispatcher = $dispatcher;
40 42
        return $this;
41
    }
42
43
    /**
44
     * Get event dispatcher.
45
     *
46
     * @return EventDispatcherInterface
47
     */
48 24
    public function getEventDispatcher()
49
    {
50 24
        if (null === $this->eventDispatcher) {
51
            throw new \LogicException('Event dispatcher was not set');
52
        }
53
54 24
        return $this->eventDispatcher;
55
    }
56
}
57