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 |
||
| 34 | class Applications extends AriClientAware |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * List all getApplications. |
||
| 38 | * |
||
| 39 | * @return Application[] |
||
| 40 | */ |
||
| 41 | View Code Duplication | public function getApplications() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Get details of an application. |
||
| 56 | * |
||
| 57 | * @param $applicationName |
||
| 58 | * @return Application |
||
| 59 | * @throws NotFoundException |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function getApplication($applicationName) |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Subscribe an application to a event source. Returns the state of the application after the subscriptions have changed |
||
| 75 | * |
||
| 76 | * @param string $applicationName Application's name |
||
| 77 | * @param string $eventSource (required) URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. Allows comma separated values. |
||
| 78 | * @return Application |
||
| 79 | * @throws InvalidParameterException |
||
| 80 | * @throws NotFoundException |
||
| 81 | * @throws UnprocessableEntityException Event source does not exist. |
||
| 82 | */ |
||
| 83 | public function subscribe($applicationName, $eventSource) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Unsubscribe an application from an event source. Returns the state of the application after the subscriptions have changed |
||
| 101 | * |
||
| 102 | * @param string $applicationName Application's name |
||
| 103 | * @param string $eventSource (required) URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName} Allows comma separated values. |
||
| 104 | * @return Application |
||
| 105 | * @throws ConflictException |
||
| 106 | * @throws InvalidParameterException |
||
| 107 | * @throws NotFoundException |
||
| 108 | * @throws UnprocessableEntityException |
||
| 109 | */ |
||
| 110 | View Code Duplication | public function unsubscribe($applicationName, $eventSource) |
|
| 121 | } |
||
| 122 |