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 |
||
8 | class HttpAuth extends Object implements IAuth { |
||
|
|||
9 | |||
10 | public static function authenticate($email, $password) { |
||
16 | |||
17 | /** |
||
18 | * @param Member $user |
||
19 | * @return ApiSession |
||
20 | */ |
||
21 | View Code Duplication | public static function createSession($user) { |
|
33 | |||
34 | View Code Duplication | public static function delete($request) { |
|
42 | |||
43 | |||
44 | /** |
||
45 | * @param SS_HTTPRequest $request |
||
46 | * @return Member |
||
47 | */ |
||
48 | public static function current($request) { |
||
52 | |||
53 | /** |
||
54 | * @return Member |
||
55 | */ |
||
56 | protected static function getBasicAuthMember(){ |
||
63 | |||
64 | } |
||
65 |
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.