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 |
||
| 6 | class xKerman_Restricted_StringHandler implements xKerman_Restricted_HandlerInterface |
||
|
|
|||
| 7 | { |
||
| 8 | /** @var integer */ |
||
| 9 | const CLOSE_STRING_LENGTH = 2; |
||
| 10 | /** |
||
| 11 | * parse give `$source` as PHP serialized string |
||
| 12 | * |
||
| 13 | * @param Source $source parser input |
||
| 14 | * @param string $args string length |
||
| 15 | * @return array parser result |
||
| 16 | * @throws UnserializeFailedException |
||
| 17 | */ |
||
| 18 | View Code Duplication | public function handle(xKerman_Restricted_Source $source, $args) |
|
| 25 | } |
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.