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 |
||
| 9 | class MailInABoxChangePasswordDriver implements \RainLoop\Providers\ChangePassword\ChangePasswordInterface |
||
|
|
|||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | private $sAllowedEmails = ''; |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $sHost = ''; |
||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $sAdminUser = ''; |
||
| 23 | /** |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | private $sAdminPassword = ''; |
||
| 27 | /** |
||
| 28 | * @var \MailSo\Log\Logger |
||
| 29 | */ |
||
| 30 | private $oLogger = null; |
||
| 31 | /** |
||
| 32 | * @param string $sHost |
||
| 33 | * @param string $sAdminUser |
||
| 34 | * @param string $sAdminPassword |
||
| 35 | * |
||
| 36 | * @return \MailInABoxChangePasswordDriver |
||
| 37 | */ |
||
| 38 | public function SetConfig($sHost, $sAdminUser, $sAdminPassword) |
||
| 45 | /** |
||
| 46 | * @param string $sAllowedEmails |
||
| 47 | * |
||
| 48 | * @return \MailInABoxChangePasswordDriver |
||
| 49 | */ |
||
| 50 | public function SetAllowedEmails($sAllowedEmails) |
||
| 55 | /** |
||
| 56 | * @param \MailSo\Log\Logger $oLogger |
||
| 57 | * |
||
| 58 | * @return \MailInABoxChangePasswordDriver |
||
| 59 | */ |
||
| 60 | public function SetLogger($oLogger) |
||
| 68 | /** |
||
| 69 | * @param string $sDesc |
||
| 70 | * @param int $iType = \MailSo\Log\Enumerations\Type::INFO |
||
| 71 | * |
||
| 72 | * @return \MailInABoxChangePasswordDriver |
||
| 73 | */ |
||
| 74 | public function WriteLog($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO) |
||
| 82 | /** |
||
| 83 | * @param \RainLoop\Model\Account $oAccount |
||
| 84 | * |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | public function PasswordChangePossibility($oAccount) |
||
| 92 | /** |
||
| 93 | * @param \RainLoop\Model\Account $oAccount |
||
| 94 | * @param string $sPrevPassword |
||
| 95 | * @param string $sNewPassword |
||
| 96 | * |
||
| 97 | * @return bool |
||
| 98 | */ |
||
| 99 | public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword) |
||
| 157 | } |
||
| 158 |
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.