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 IspConfigChangePasswordDriver implements \RainLoop\Providers\ChangePassword\ChangePasswordInterface |
||
|
|
|||
| 4 | { |
||
| 5 | /** |
||
| 6 | * @var string |
||
| 7 | */ |
||
| 8 | private $sDsn = ''; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | private $sUser = ''; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $sPassword = ''; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $sAllowedEmails = ''; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var \MailSo\Log\Logger |
||
| 27 | */ |
||
| 28 | private $oLogger = null; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $sDsn |
||
| 32 | * @param string $sUser |
||
| 33 | * @param string $sPassword |
||
| 34 | * |
||
| 35 | * @return \IspConfigChangePasswordDriver |
||
| 36 | */ |
||
| 37 | public function SetConfig($sDsn, $sUser, $sPassword) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $sAllowedEmails |
||
| 48 | * |
||
| 49 | * @return \IspConfigChangePasswordDriver |
||
| 50 | */ |
||
| 51 | public function SetAllowedEmails($sAllowedEmails) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param \MailSo\Log\Logger $oLogger |
||
| 59 | * |
||
| 60 | * @return \IspConfigChangePasswordDriver |
||
| 61 | */ |
||
| 62 | public function SetLogger($oLogger) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param \RainLoop\Model\Account $oAccount |
||
| 74 | * |
||
| 75 | * @return bool |
||
| 76 | */ |
||
| 77 | public function PasswordChangePossibility($oAccount) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param \RainLoop\Model\Account $oAccount |
||
| 85 | * @param string $sPrevPassword |
||
| 86 | * @param string $sNewPassword |
||
| 87 | * |
||
| 88 | * @return bool |
||
| 89 | */ |
||
| 90 | public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword) |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @param string $sPassword |
||
| 137 | * @return string |
||
| 138 | */ |
||
| 139 | View Code Duplication | private function cryptPassword($sPassword) |
|
| 151 | } |
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.