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 Export extends SymfonyCommand |
||
18 | { |
||
19 | |||
20 | use RedisTrait; |
||
21 | |||
22 | const BULK_SIZE = 100; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | protected function configure() |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | protected function execute(InputInterface $input, OutputInterface $output) |
||
55 | |||
56 | /** |
||
57 | * @param string $key |
||
58 | * @return string[] |
||
59 | * @throws Exception |
||
60 | */ |
||
61 | protected function dump($key) : array |
||
89 | |||
90 | /** |
||
91 | * @param string $value |
||
92 | * @return string |
||
93 | */ |
||
94 | private function escape($value) |
||
100 | |||
101 | /** |
||
102 | * @param string $key |
||
103 | * @param array $parts |
||
104 | */ |
||
105 | protected function processZset($key, array &$parts) |
||
124 | |||
125 | /** |
||
126 | * @param string $key |
||
127 | * @param array $parts |
||
128 | */ |
||
129 | protected function processSet($key, array &$parts) |
||
141 | /** |
||
142 | * @param string $key |
||
143 | * @param array $parts |
||
144 | */ |
||
145 | protected function processList($key, array &$parts) |
||
156 | |||
157 | /** |
||
158 | * @param string $key |
||
159 | * @param array $parts |
||
160 | */ |
||
161 | private function processHash($key, array &$parts) |
||
179 | |||
180 | /** |
||
181 | * @param string $key |
||
182 | * @param array $parts |
||
183 | */ |
||
184 | private function processString($key, array &$parts) |
||
188 | } |
||
189 |