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 Bridges extends MediaBase |
||
34 | { |
||
35 | /** |
||
36 | * List all active bridges in Asterisk. |
||
37 | * |
||
38 | * @return Bridge[] |
||
39 | */ |
||
40 | View Code Duplication | public function getBridges() |
|
52 | |||
53 | /** |
||
54 | * Create a new bridge. This bridge persists until it has been shut down, or Asterisk has been shut down. |
||
55 | * |
||
56 | * @param string $bridgeId Unique ID to give to the bridge being created. |
||
57 | * @param string $type Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media). |
||
58 | * @param string $name Name to give to the bridge being created. |
||
59 | * @return Bridge |
||
60 | */ |
||
61 | 12 | public function createBridge($bridgeId, $type, $name) |
|
74 | |||
75 | /** |
||
76 | * Create a new bridge or updates an existing one. This bridge persists until it has been shut down, or Asterisk has been shut down. |
||
77 | * |
||
78 | * @param string $bridgeId Unique ID to give to the bridge being created. |
||
79 | * @param string $type Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set. |
||
80 | * @param string $name Set the name of the bridge. |
||
81 | * @return Bridge |
||
82 | */ |
||
83 | public function updateBridge($bridgeId, $type, $name) |
||
95 | |||
96 | /** |
||
97 | * Get bridge details. |
||
98 | * |
||
99 | * @param string $bridgeId Bridge's id |
||
100 | * @return Bridge |
||
101 | * @throws NotFoundException |
||
102 | */ |
||
103 | 2 | View Code Duplication | public function getBridge($bridgeId) |
114 | |||
115 | /** |
||
116 | * Shut down a bridge. If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. |
||
117 | * |
||
118 | * @param string $bridgeId Bridge's id |
||
119 | * @throws NotFoundException |
||
120 | */ |
||
121 | 2 | public function deleteBridge($bridgeId) |
|
130 | |||
131 | /** |
||
132 | * Add a channel to a bridge. |
||
133 | * |
||
134 | * @param string $bridgeId Bridge's id |
||
135 | * @param string $channel (required) Ids of channels to add to bridge. Allows comma separated values. |
||
136 | * @param string $role Channel's role in the bridge |
||
137 | * @throws NotFoundException |
||
138 | * @throws ConflictException |
||
139 | * @throws UnprocessableEntityException |
||
140 | */ |
||
141 | public function addChannel($bridgeId, $channel, $role = null) |
||
155 | |||
156 | /** |
||
157 | * Remove a channel from a bridge. |
||
158 | * |
||
159 | * @param string $bridgeId Bridge's id |
||
160 | * @param string $channel (required) Ids of channels to remove from bridge. Allows comma separated values. |
||
161 | * @throwe InvalidParameterException |
||
162 | * @throws NotFoundException |
||
163 | * @throws ConflictException |
||
164 | * @throws UnprocessableEntityException |
||
165 | */ |
||
166 | public function removeChannel($bridgeId, $channel) |
||
179 | |||
180 | /** |
||
181 | * Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with |
||
182 | * two or fewer participants. |
||
183 | * |
||
184 | * @param string $id Bridge's id |
||
185 | * @param string $channelId Channel's id |
||
186 | * @throws NotFoundException |
||
187 | * @throws ConflictException |
||
188 | * @throws UnprocessableEntityException |
||
189 | */ |
||
190 | public function setVideoSource($id, $channelId) |
||
199 | |||
200 | /** |
||
201 | * Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with |
||
202 | * two or fewer participants. When no explicit video source is set, talk detection will be used to determine the |
||
203 | * active video stream. |
||
204 | * |
||
205 | * @param string $id Bridge's id |
||
206 | * @throws NotFoundException |
||
207 | * @throws ConflictException |
||
208 | * @throws UnprocessableEntityException |
||
209 | */ |
||
210 | public function clearVideoSource($id) |
||
219 | |||
220 | public function getType() |
||
224 | } |
||
225 |