ExecutorDispatcherEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 118
Duplicated Lines 13.56 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 2
cbo 3
dl 16
loc 118
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 8 8 2
A setMethod() 0 6 1
A getFixture() 8 8 2
A setFixture() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\DoctrineFixtureModule\Event;
7
8
use Doctrine\Fixture\Fixture;
9
use Nnx\DoctrineFixtureModule\Executor\ExecutorAwareTrait;
10
use Zend\EventManager\Event;
11
12
/**
13
 * Class ExecutorDispatcherEvent
14
 *
15
 * @package Nnx\DoctrineFixtureModule\Event
16
 */
17
class ExecutorDispatcherEvent extends Event
18
{
19
    use ExecutorAwareTrait;
20
21
    /**
22
     * Событие бросаемое при старте Executor'a
23
     *
24
     * @var string
25
     */
26
    const RUN_EXECUTOR_EVENT = 'runExecutorEvent.executorDispatcher';
27
28
    /**
29
     * Событие бросаемое при старте фикстуры
30
     *
31
     * @var string
32
     */
33
    const RUN_FIXTURE_EVENT = 'runFixtureEvent.executorDispatcher';
34
35
    /**
36
     * Событие бросаемое после окончания работы фикстуры
37
     *
38
     * @var string
39
     */
40
    const FINISH_FIXTURE_EVENT = 'finishFixtureEvent.executorDispatcher';
41
42
    /**
43
     * Событие бросаемое после окончания работы Executor'a
44
     *
45
     * @var string
46
     */
47
    const FINISH_EXECUTOR_EVENT = 'finishExecutorEvent.executorDispatcher';
48
49
    /**
50
     * Имя действия когда происходит загрузка данных из фикстуры
51
     *
52
     * @var string
53
     */
54
    const IMPORT = 'import';
55
56
    /**
57
     * Имя действия когда происходит откат данных
58
     *
59
     * @var string
60
     */
61
    const PURGE = 'purge';
62
63
    /**
64
     * Действие которое выполняет фикстура
65
     *
66
     * @var string
67
     */
68
    protected $method;
69
70
    /**
71
     * Обрабатываемя фикстура
72
     *
73
     * @var Fixture
74
     */
75
    protected $fixture;
76
77
    /**
78
     * Возвращает имя действия которое выполняет фикстура
79
     *
80
     * @return string
81
     * @throws \Nnx\DoctrineFixtureModule\Event\Exception\RuntimeException
82
     */
83 View Code Duplication
    public function getMethod()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
    {
85
        if (null === $this->method) {
86
            $errMsg = 'Method not specified';
87
            throw new Exception\RuntimeException($errMsg);
88
        }
89
        return $this->method;
90
    }
91
92
    /**
93
     * Устанавливает имя действия которое выполняет фикстура
94
     *
95
     * @param string $method
96
     *
97
     * @return $this
98
     */
99
    public function setMethod($method)
100
    {
101
        $this->method = $method;
102
103
        return $this;
104
    }
105
106
    /**
107
     * Возвращает обрабатываемую фикстуру
108
     *
109
     * @return Fixture
110
     * @throws \Nnx\DoctrineFixtureModule\Event\Exception\RuntimeException
111
     */
112 View Code Duplication
    public function getFixture()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
    {
114
        if (null === $this->fixture) {
115
            $errMsg = 'Fixture not specified';
116
            throw new Exception\RuntimeException($errMsg);
117
        }
118
        return $this->fixture;
119
    }
120
121
    /**
122
     * Устанавливает обрабатываемую фикстуру
123
     *
124
     * @param Fixture $fixture
125
     *
126
     * @return $this
127
     */
128
    public function setFixture(Fixture $fixture)
129
    {
130
        $this->fixture = $fixture;
131
132
        return $this;
133
    }
134
}
135