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 |
||
| 33 | class Playbacks extends AriClientAware |
||
| 34 | { |
||
| 35 | const OPERATION_PAUSE = 'pause'; |
||
| 36 | const OPERATION_UNPAUSE = 'unpause'; |
||
| 37 | const OPERATION_REVERSE = 'reverse'; |
||
| 38 | const OPERATION_FORWARD = 'forward'; |
||
| 39 | const OPERATION_RESTART = 'restart'; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get a playback's details. |
||
| 43 | * |
||
| 44 | * @param string $playbackId Playback's id |
||
| 45 | * @return Playback |
||
| 46 | * @throws NotFoundException |
||
| 47 | */ |
||
| 48 | View Code Duplication | public function getPlayback($playbackId) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * Stop a playback. |
||
| 62 | * |
||
| 63 | * @param string $playbackId Playback's id |
||
| 64 | * @throws NotFoundException |
||
| 65 | */ |
||
| 66 | public function stopPlayback($playbackId) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Control a playback. |
||
| 78 | * |
||
| 79 | * @param string $playbackId Playback's id |
||
| 80 | * @param string $operation (required) Operation to perform on the playback. Allowed values: restart, pause, unpause, reverse, forward. |
||
| 81 | * @throws ConflictException |
||
| 82 | * @throws InvalidParameterException |
||
| 83 | * @throws NotFoundException |
||
| 84 | */ |
||
| 85 | public function controlPlayback($playbackId, $operation) |
||
| 98 | } |
||
| 99 |