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 |
||
| 4 | class PasswordResetEmail extends FlipsideProfileEmail |
||
| 5 | { |
||
| 6 | /** An instance of the Settings class */ |
||
| 7 | protected $settings; |
||
| 8 | /** The prfiles app URL */ |
||
| 9 | protected $profilesUrl |
||
| 10 | |||
| 11 | |||
| 12 | public function __construct($user) |
||
|
|
|||
| 13 | { |
||
| 14 | parent::__construct($user); |
||
| 15 | $this->addToAddress($user->mail, $user->displayName); |
||
| 16 | $this->settings = \Settings::getInstance(); |
||
| 17 | $this->profilesUrl = $this->settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getSubject() |
||
| 21 | { |
||
| 22 | return 'Burning Flipside Password Reset'; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getHTMLBody() |
||
| 26 | { |
||
| 27 | return 'Someone (quite possibly you) has requested a password reset of your Flipside account.<br/> |
||
| 28 | To reset your password click on the link below.<br/> |
||
| 29 | <a href="'.$this->profilesUrl.'/change.php?hash='.$this->user->getPasswordResetHash().'">Reset Password</a><br/> |
||
| 30 | If you did not request this reset, don\'t worry. This email was sent only to you and your password has not been changed.<br/> |
||
| 31 | If you receive many of these requests, you can notify the technology team ([email protected]).<br/> |
||
| 32 | Thank you,<br/> |
||
| 33 | Burning Flipside Technology Team'; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getTextBody() |
||
| 37 | { |
||
| 38 | return 'Someone (quite possibly you) has requested a password reset of your Flipside account. |
||
| 39 | To reset your password copy the following URL into your browser. |
||
| 48 |