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 |
||
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() |
|
91 | |||
92 | /** |
||
93 | * Устанавливает имя действия которое выполняет фикстура |
||
94 | * |
||
95 | * @param string $method |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function setMethod($method) |
||
105 | |||
106 | /** |
||
107 | * Возвращает обрабатываемую фикстуру |
||
108 | * |
||
109 | * @return Fixture |
||
110 | * @throws \Nnx\DoctrineFixtureModule\Event\Exception\RuntimeException |
||
111 | */ |
||
112 | View Code Duplication | public function getFixture() |
|
120 | |||
121 | /** |
||
122 | * Устанавливает обрабатываемую фикстуру |
||
123 | * |
||
124 | * @param Fixture $fixture |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | public function setFixture(Fixture $fixture) |
||
134 | } |
||
135 |
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.