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 TestMailerToFile extends Mailer |
||
9 | { |
||
10 | private static $show_all_details = false; |
||
11 | |||
12 | private static $file_to_write_to = "assets/emails.txt"; |
||
13 | |||
14 | private static $separation_string = " |
||
15 | -------------------------------------------------------------------------------------------------------------------------------------"; |
||
16 | |||
17 | /** |
||
18 | * Send a plain-text email |
||
19 | */ |
||
20 | public function sendPlain($to, $from, $subject, $plainContent, $attachedFiles = false, $customheaders = false) |
||
40 | |||
41 | /** |
||
42 | * Send a multi-part HTML email |
||
43 | */ |
||
44 | public function sendHTML($to, $from, $subject, $htmlContent, $attachedFiles = false, $customheaders = false, $plainContent = false, $inlineImages = false) |
||
66 | |||
67 | protected function writeToFile($string) |
||
75 | } |
||
76 |