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 |
||
| 10 | class FacebookIdentifier extends DataObjectDecorator |
||
|
|
|||
| 11 | { |
||
| 12 | public function extraStatics() |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * connect and disconnect button |
||
| 39 | * @return Object (IsConnected, Link, ConnectedName, ConnectedImageURL) |
||
| 40 | */ |
||
| 41 | public function getFacebookButton($backURL = "") |
||
| 45 | |||
| 46 | /** |
||
| 47 | * |
||
| 48 | * user has logged in with facebook before? |
||
| 49 | * @return Boolean |
||
| 50 | */ |
||
| 51 | public function hasFacebook() |
||
| 55 | |||
| 56 | /** |
||
| 57 | * user is currenctly connected to Faceboo |
||
| 58 | * |
||
| 59 | * |
||
| 60 | */ |
||
| 61 | public function isConnectedToFacebook() |
||
| 65 | |||
| 66 | |||
| 67 | /** |
||
| 68 | * link to profile |
||
| 69 | * @return String |
||
| 70 | */ |
||
| 71 | public function FacebookLink() |
||
| 81 | |||
| 82 | View Code Duplication | public function onBeforeWrite() |
|
| 96 | } |
||
| 97 |
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.