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 |
||
16 | class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * Registered transport currently used. |
||
20 | * |
||
21 | * @var Swift_Transport |
||
22 | */ |
||
23 | private $_currentTransport; |
||
24 | |||
25 | /** |
||
26 | * Creates a new FailoverTransport. |
||
27 | */ |
||
28 | public function __construct() |
||
32 | |||
33 | /** |
||
34 | * Send the given Message. |
||
35 | * |
||
36 | * Recipient/sender data will be retrieved from the Message API. |
||
37 | 8 | * The return value is the number of recipients who were accepted for delivery. |
|
38 | * |
||
39 | 8 | * @param Swift_Mime_Message $message |
|
40 | 8 | * @param string[] $failedRecipients An array of failures by-reference |
|
41 | 8 | * |
|
42 | * @return int |
||
43 | 8 | * @throws Swift_TransportException |
|
44 | 8 | */ |
|
45 | View Code Duplication | public function send(Swift_Mime_Message $message, &$failedRecipients = null) |
|
78 | |||
79 | protected function _getNextTransport() |
||
87 | |||
88 | protected function _killCurrentTransport() |
||
93 | } |
||
94 |
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.