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 |
||
3 | class Explanation extends Abbreviation implements Shortcodable |
||
|
|||
4 | { |
||
5 | |||
6 | |||
7 | private static $singular_name = 'Explanation'; |
||
8 | |||
9 | private static $plural_name = 'Explanations'; |
||
10 | |||
11 | |||
12 | public function forTemplate() |
||
17 | |||
18 | /** |
||
19 | * Parse the shortcode and render as a string, probably with a template |
||
20 | * @param array $arguments the list of attributes of the shortcode |
||
21 | * @param string $content the shortcode content |
||
22 | * @param ShortcodeParser $parser the ShortcodeParser instance |
||
23 | * @param string $shortcode the raw shortcode being parsed |
||
24 | * @return String |
||
25 | **/ |
||
26 | View Code Duplication | public static function parse_shortcode($arguments, $content, $parser, $shortcode) |
|
47 | |||
48 | /** |
||
49 | * returns a list of fields for editing the shortcode's attributes |
||
50 | * @return Fieldlist |
||
51 | **/ |
||
52 | public static function shortcode_attribute_fields() |
||
56 | } |
||
57 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.