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 | * Returns all recently created or updated engagements. |
||
| 30 | * |
||
| 31 | * @param array $params Array of optional parameters ['count', 'offset', 'since] |
||
| 32 | * |
||
| 33 | * @see https://developers.hubspot.com/docs/methods/engagements/get-recent-engagements |
||
| 34 | * |
||
| 35 | * @return \SevenShores\Hubspot\Http\Response |
||
| 36 | */ |
||
| 37 | function recent($params = []) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param int $id The engagement id. |
||
| 48 | * @param array $engagement The engagement engagement to update. |
||
| 49 | * @param array $metadata The engagement metadata to update. |
||
| 50 | * @return \SevenShores\Hubspot\Http\Response |
||
| 51 | */ |
||
| 52 | View Code Duplication | function update($id, $engagement, $metadata) |
|
| 63 | |||
| 64 | /** |
||
| 65 | * @param int $id |
||
| 66 | * @return \SevenShores\Hubspot\Http\Response |
||
| 67 | */ |
||
| 68 | function delete($id) |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param int $id |
||
| 77 | * @return \SevenShores\Hubspot\Http\Response |
||
| 78 | */ |
||
| 79 | function get($id) |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Returns all engagements. |
||
| 88 | * |
||
| 89 | * @param array $params Array of optional parameters ['limit', 'offset'] |
||
| 90 | * |
||
| 91 | * @see http://developers.hubspot.com/docs/methods/engagements/get-all-engagements |
||
| 92 | * |
||
| 93 | * @return \SevenShores\Hubspot\Http\Response |
||
| 94 | */ |
||
| 95 | public function all($params = []) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @param int $id |
||
| 106 | * @param string $object_type |
||
| 107 | * @param int $object_id |
||
| 108 | * @return \SevenShores\Hubspot\Http\Response |
||
| 109 | **/ |
||
| 110 | function associate($id, $object_type, $object_id) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @param string $object_type |
||
| 119 | * @param int $object_id |
||
| 120 | * @return \SevenShores\Hubspot\Http\Response |
||
| 121 | **/ |
||
| 122 | function associated($object_type, $object_id) |
||
| 128 | } |
||
| 129 |
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.