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 |
||
27 | class Member extends HttpApi |
||
28 | { |
||
29 | /** |
||
30 | * Returns a paginated list of members of the mailing list. |
||
31 | * |
||
32 | * @param string $address Address of the mailing list |
||
33 | * @param int $limit Maximum number of records to return (optional: 100 by default) |
||
34 | * @param bool|null $subscribed `true` to lists subscribed, `false` for unsubscribed. list all if null |
||
35 | * |
||
36 | * @return IndexResponse |
||
37 | * |
||
38 | * @throws \Exception |
||
39 | */ |
||
40 | 3 | public function index(string $address, int $limit = 100, bool $subscribed = null) |
|
59 | |||
60 | /** |
||
61 | * Shows a single member of the mailing list. |
||
62 | * |
||
63 | * @param string $list Address of the mailing list |
||
64 | * @param string $address Address of the member |
||
65 | * |
||
66 | * @return ShowResponse |
||
67 | * |
||
68 | * @throws \Exception |
||
69 | */ |
||
70 | public function show(string $list, string $address) |
||
79 | |||
80 | /** |
||
81 | * Creates (or updates) a member of the mailing list. |
||
82 | * |
||
83 | * @param string $list Address of the mailing list |
||
84 | * @param string $address Address for the member |
||
85 | * @param string $name Name for the member (optional) |
||
86 | * @param array $vars Array of field => value pairs to store additional data |
||
87 | * @param bool $subscribed `true` to add as subscribed (default), `false` as unsubscribed |
||
88 | * @param bool $upsert `true` to update member if present, `false` to raise error in case of a duplicate member (default) |
||
89 | * |
||
90 | * @return CreateResponse |
||
91 | * |
||
92 | * @throws \Exception |
||
93 | */ |
||
94 | 3 | public function create(string $list, string $address, string $name = null, array $vars = [], bool $subscribed = true, bool $upsert = false) |
|
112 | |||
113 | /** |
||
114 | * Adds multiple members (up to 1000) to the mailing list. |
||
115 | * |
||
116 | * @param string $list Address of the mailing list |
||
117 | * @param array $members Array of members, each item should be either a single string address or an array of member properties |
||
118 | * @param bool $upsert `true` to update existing members, `false` (default) to ignore duplicates |
||
119 | * |
||
120 | * @return UpdateResponse |
||
121 | * |
||
122 | * @throws \Exception |
||
123 | */ |
||
124 | 3 | public function createMultiple(string $list, array $members, $upsert = false) |
|
176 | |||
177 | /** |
||
178 | * Updates a member on the mailing list. |
||
179 | * |
||
180 | * @param string $list Address of the mailing list |
||
181 | * @param string $address Address of the member |
||
182 | * @param array $parameters Array of key => value pairs to update |
||
183 | * |
||
184 | * @return UpdateResponse |
||
185 | * |
||
186 | * @throws \Exception |
||
187 | */ |
||
188 | 2 | public function update(string $list, string $address, array $parameters = []) |
|
218 | |||
219 | /** |
||
220 | * Removes a member from the mailing list. |
||
221 | * |
||
222 | * @param string $list Address of the mailing list |
||
223 | * @param string $address Address of the member |
||
224 | * |
||
225 | * @return DeleteResponse |
||
226 | * |
||
227 | * @throws \Exception |
||
228 | */ |
||
229 | 1 | View Code Duplication | public function delete(string $list, string $address) |
238 | } |
||
239 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.