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 |
||
9 | class EntryBook extends Entry |
||
|
|||
10 | { |
||
11 | public $book; |
||
12 | |||
13 | /** |
||
14 | * EntryBook constructor. |
||
15 | * @param string $ptitle |
||
16 | * @param integer $pid |
||
17 | * @param string $pcontent |
||
18 | * @param string $pcontentType |
||
19 | * @param array $plinkArray |
||
20 | * @param Book $pbook |
||
21 | */ |
||
22 | 41 | public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
|
27 | |||
28 | View Code Duplication | public function getCoverThumbnail () { |
|
37 | |||
38 | View Code Duplication | public function getCover () { |
|
47 | } |
||
48 |
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.