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 Forms extends Resource |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Submit data to a form. |
||
| 9 | * |
||
| 10 | * @see http://developers.hubspot.com/docs/methods/forms/submit_form |
||
| 11 | * |
||
| 12 | * Send form submission data to HubSpot. Form submissions from external sources can be made to any registered |
||
| 13 | * HubSpot form. You can see a list of forms on your portal by going to the Contacts > Forms page |
||
| 14 | * |
||
| 15 | * @param int $portal_id |
||
| 16 | * @param string $form_guid |
||
| 17 | * @param array $form |
||
| 18 | * @return \SevenShores\Hubspot\Http\Response |
||
| 19 | */ |
||
| 20 | View Code Duplication | function submit($portal_id, $form_guid, $form) |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Return all forms that have been created in the portal. |
||
| 31 | * |
||
| 32 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_forms |
||
| 33 | * |
||
| 34 | * @return \SevenShores\Hubspot\Http\Response |
||
| 35 | */ |
||
| 36 | function all() |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Return a single form based on the unique ID of that form. |
||
| 45 | * |
||
| 46 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_form |
||
| 47 | * |
||
| 48 | * @param string $form_guid |
||
| 49 | * @return \SevenShores\Hubspot\Http\Response |
||
| 50 | */ |
||
| 51 | function getById($form_guid) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Create a new form. |
||
| 60 | * |
||
| 61 | * @see http://developers.hubspot.com/docs/methods/forms/v2/create_form |
||
| 62 | * |
||
| 63 | * @param array $form |
||
| 64 | * @return \SevenShores\Hubspot\Http\Response |
||
| 65 | */ |
||
| 66 | function create($form) |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Update an existing form. |
||
| 77 | * |
||
| 78 | * @see http://developers.hubspot.com/docs/methods/forms/v2/update_form |
||
| 79 | * |
||
| 80 | * @param string $form_guid |
||
| 81 | * @param array $form |
||
| 82 | * @return \SevenShores\Hubspot\Http\Response |
||
| 83 | */ |
||
| 84 | View Code Duplication | function update($form_guid, $form) |
|
| 92 | |||
| 93 | /** |
||
| 94 | * Delete an existing form. |
||
| 95 | * |
||
| 96 | * @see http://developers.hubspot.com/docs/methods/forms/v2/delete_form |
||
| 97 | * |
||
| 98 | * @param string $form_guid |
||
| 99 | * @return \SevenShores\Hubspot\Http\Response |
||
| 100 | */ |
||
| 101 | function delete($form_guid) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Get all fields from a form. |
||
| 110 | * |
||
| 111 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_fields |
||
| 112 | * |
||
| 113 | * @param string $form_guid |
||
| 114 | * @return \SevenShores\Hubspot\Http\Response |
||
| 115 | */ |
||
| 116 | function getFields($form_guid) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Get a single field from a form. |
||
| 125 | * |
||
| 126 | * @see http://developers.hubspot.com/docs/methods/forms/v2/get_field |
||
| 127 | * |
||
| 128 | * @param string $form_guid |
||
| 129 | * @param string $name |
||
| 130 | * @return \SevenShores\Hubspot\Http\Response |
||
| 131 | */ |
||
| 132 | function getFieldByName($form_guid, $name) |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Get all submissions from a form. |
||
| 141 | * |
||
| 142 | * @see https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form |
||
| 143 | * |
||
| 144 | * @param string $form_guid |
||
| 145 | * @return \SevenShores\Hubspot\Http\Response |
||
| 146 | */ |
||
| 147 | function getSubmissions($form_guid, $params = []){ |
||
| 154 | |||
| 155 | } |
||
| 156 |
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.