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 |
||
| 31 | class Mailboxes extends AriClientAware |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * List all mailboxes. |
||
| 35 | * |
||
| 36 | * @return Mailbox[] |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function getMailboxes() |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Retrieve the current state of a mailbox. |
||
| 53 | * |
||
| 54 | * @param string $mailboxName Name of the mailbox |
||
| 55 | * @return Mailbox |
||
| 56 | * @throws NotFoundException |
||
| 57 | */ |
||
| 58 | View Code Duplication | public function getMailbox($mailboxName) |
|
| 69 | |||
| 70 | /** |
||
| 71 | * Change the state of a mailbox. (Note - implicitly creates the mailbox). |
||
| 72 | * |
||
| 73 | * @param string $mailboxName Name of the mailbox |
||
| 74 | * @param int $oldMessages (required) Count of old messages in the mailbox |
||
| 75 | * @param int $newMessages (required) Count of new messages in the mailbox |
||
| 76 | * @throws NotFoundException |
||
| 77 | */ |
||
| 78 | public function updateMailbox($mailboxName, $oldMessages, $newMessages) |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Destroy a mailbox. |
||
| 95 | * |
||
| 96 | * @param string $mailboxName Name of the mailbox |
||
| 97 | * @throws NotFoundException |
||
| 98 | */ |
||
| 99 | public function deleteMailbox($mailboxName) |
||
| 108 | } |
||
| 109 |