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 |
||
| 29 | class Playback extends Resource |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * @var string ID for this playback operation |
||
| 33 | */ |
||
| 34 | private $id; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var string (optional) - For media types that support multiple languages, the language requested for playback. |
||
| 38 | */ |
||
| 39 | private $language; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string URI for the media to play back. |
||
| 43 | */ |
||
| 44 | private $mediaUri; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var string Current state of the playback operation. |
||
| 48 | */ |
||
| 49 | private $state; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var string URI for the channel or bridge to play the media on |
||
| 53 | */ |
||
| 54 | private $targetUri; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string ID for this playback operation |
||
| 58 | */ |
||
| 59 | public function getId() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string (optional) - For media types that support multiple languages, the language requested for playback. |
||
| 66 | */ |
||
| 67 | public function getLanguage() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return string URI for the media to play back. |
||
| 74 | */ |
||
| 75 | public function getMediaUri() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return string Current state of the playback operation. |
||
| 82 | */ |
||
| 83 | public function getState() |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @return string URI for the channel or bridge to play the media on |
||
| 90 | */ |
||
| 91 | public function getTargetUri() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @param callable $callback |
||
| 98 | */ |
||
| 99 | public function onPlaybackStarted(callable $callback) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @param callable $callback |
||
| 106 | */ |
||
| 107 | public function oncePlaybackStarted(callable $callback) |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @param callable $callback |
||
| 114 | */ |
||
| 115 | public function onPlaybackContinuing(callable $callback) |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @param callable $callback |
||
| 122 | */ |
||
| 123 | public function oncePlaybackContinuing(callable $callback) |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @param callable $callback |
||
| 130 | */ |
||
| 131 | public function onPlaybackFinished(callable $callback) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @param callable $callback |
||
| 138 | */ |
||
| 139 | public function oncePlaybackFinished(callable $callback) |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @param AriClient $client |
||
| 146 | * @param string $response |
||
| 147 | */ |
||
| 148 | View Code Duplication | public function __construct(AriClient $client, $response) |
|
| 158 | |||
| 159 | } |
||
| 160 |