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 LinkedinIdentifier extends DataObjectDecorator |
||
|
|
|||
| 4 | { |
||
| 5 | public function extraStatics() |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * connect and disconnect button |
||
| 25 | * @return Object (IsConnected, Link, ConnectedName, ConnectedImageURL) |
||
| 26 | */ |
||
| 27 | public function getLinkedinButton($backURL = "") |
||
| 31 | |||
| 32 | /** |
||
| 33 | * |
||
| 34 | * user has logged in with facebook before? |
||
| 35 | * @return Boolean |
||
| 36 | */ |
||
| 37 | public function hasLinkedin() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * user is currenctly connected to Faceboo |
||
| 44 | * |
||
| 45 | * |
||
| 46 | */ |
||
| 47 | public function isConnectedToLinkedin() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * link to profile |
||
| 54 | * @return String |
||
| 55 | */ |
||
| 56 | public function LinkedinLink() |
||
| 63 | |||
| 64 | View Code Duplication | public function onBeforeWrite() |
|
| 78 | } |
||
| 79 |
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.