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 |
||
32 | abstract class AbstractPrimaryAuthenticationProvider extends AbstractAuthenticationProvider |
||
|
|||
33 | implements PrimaryAuthenticationProvider |
||
34 | { |
||
35 | |||
36 | public function continuePrimaryAuthentication( array $reqs ) { |
||
39 | |||
40 | public function postAuthentication( $user, AuthenticationResponse $response ) { |
||
42 | |||
43 | public function testUserCanAuthenticate( $username ) { |
||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | * @note Reimplement this if you do anything other than |
||
51 | * User::getCanonicalName( $req->username ) to determine the user being |
||
52 | * authenticated. |
||
53 | */ |
||
54 | public function providerNormalizeUsername( $username ) { |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | * @note Reimplement this if self::getAuthenticationRequests( AuthManager::ACTION_REMOVE ) |
||
62 | * doesn't return requests that will revoke all access for the user. |
||
63 | */ |
||
64 | View Code Duplication | public function providerRevokeAccessForUser( $username ) { |
|
74 | |||
75 | public function providerAllowsPropertyChange( $property ) { |
||
78 | |||
79 | public function testForAccountCreation( $user, $creator, array $reqs ) { |
||
82 | |||
83 | public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) { |
||
86 | |||
87 | public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) { |
||
90 | |||
91 | public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) { |
||
93 | |||
94 | public function testUserForCreation( $user, $autocreate, array $options = [] ) { |
||
95 | return \StatusValue::newGood(); |
||
96 | } |
||
97 | |||
98 | public function autoCreatedAccount( $user, $source ) { |
||
100 | |||
101 | public function beginPrimaryAccountLink( $user, array $reqs ) { |
||
110 | |||
111 | public function continuePrimaryAccountLink( $user, array $reqs ) { |
||
114 | |||
115 | public function postAccountLink( $user, AuthenticationResponse $response ) { |
||
117 | |||
118 | } |
||
119 |