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 |
||
| 29 | class ParserOutputSearchDataExtractor { |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Get a list of categories, as an array with title text strings. |
||
| 33 | * |
||
| 34 | * @return string[] |
||
| 35 | */ |
||
| 36 | public function getCategories( ParserOutput $parserOutput ) { |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get a list of external links from ParserOutput, as an array of strings. |
||
| 48 | * |
||
| 49 | * @return string[] |
||
| 50 | */ |
||
| 51 | public function getExternalLinks( ParserOutput $parserOutput ) { |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Get a list of outgoing wiki links (including interwiki links), as |
||
| 57 | * an array of prefixed title strings. |
||
| 58 | * |
||
| 59 | * @return string[] |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function getOutgoingLinks( ParserOutput $parserOutput ) { |
|
| 73 | |||
| 74 | /** |
||
| 75 | * Get a list of templates used in the ParserOutput content, as prefixed title strings |
||
| 76 | * |
||
| 77 | * @return string[] |
||
| 78 | */ |
||
| 79 | View Code Duplication | public function getTemplates( ParserOutput $parserOutput ) { |
|
| 91 | |||
| 92 | } |
||
| 93 |