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 |
||
| 5 | class Engagements extends Resource |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @param array $engagement Array of engagement engagement. |
||
| 9 | * @param array $associations Array of engagement associations. |
||
| 10 | * @param array $metadata Array of engagement metadata. |
||
| 11 | * @param array $attachments Array of engagement attachments. |
||
| 12 | * @return \SevenShores\Hubspot\Http\Response |
||
| 13 | */ |
||
| 14 | function create($engagement, $associations, $metadata, $attachments = array()) |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param int $id The engagement id. |
||
| 30 | * @param array $engagement The engagement engagement to update. |
||
| 31 | * @param array $metadata The engagement metadata to update. |
||
| 32 | * @return \SevenShores\Hubspot\Http\Response |
||
| 33 | */ |
||
| 34 | View Code Duplication | function update($id, $engagement, $metadata) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param int $id |
||
| 48 | * @return \SevenShores\Hubspot\Http\Response |
||
| 49 | */ |
||
| 50 | function delete($id) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param int $id |
||
| 59 | * @return \SevenShores\Hubspot\Http\Response |
||
| 60 | */ |
||
| 61 | function get($id) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Returns all engagements. |
||
| 70 | * |
||
| 71 | * @param array $params Array of optional parameters ['limit', 'offset'] |
||
| 72 | * |
||
| 73 | * @see http://developers.hubspot.com/docs/methods/engagements/get-all-engagements |
||
| 74 | * |
||
| 75 | * @return \SevenShores\Hubspot\Http\Response |
||
| 76 | */ |
||
| 77 | public function all($params = []) |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @param int $id |
||
| 88 | * @param string $object_type |
||
| 89 | * @param int $object_id |
||
| 90 | * @return \SevenShores\Hubspot\Http\Response |
||
| 91 | **/ |
||
| 92 | function associate($id, $object_type, $object_id) |
||
| 98 | } |
||
| 99 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.