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 |
||
14 | class MyCustomOutput extends QROutputBase implements QROutputInterface{ |
||
15 | |||
16 | /** |
||
17 | * @return mixed |
||
18 | * @throws \chillerlan\QRCode\Output\QRCodeOutputException |
||
19 | */ |
||
20 | public function dump(){ |
||
21 | |||
22 | $output = ''; |
||
23 | |||
24 | for($row = 0; $row < $this->pixelCount; $row++){ |
||
25 | for($col = 0; $col < $this->pixelCount; $col++){ |
||
26 | $output .= (string)(int)$this->matrix[$row][$col]; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | return $output; |
||
31 | } |
||
32 | |||
33 | } |
||
34 | |||
40 |