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 CompanyProperties extends Resource |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Creates a property on every company object to store a specific piece of data. |
||
| 9 | * @param array $property |
||
| 10 | * |
||
| 11 | * @see http://developers.hubspot.com/docs/methods/companies/create_company_property |
||
| 12 | * |
||
| 13 | * @return \SevenShores\Hubspot\Http\Response |
||
| 14 | */ |
||
| 15 | function create($property) |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Update the specified company-level property. This does not update the value on a specified company, but instead changes the definition of the company property. |
||
| 26 | * @param string $propertyName |
||
| 27 | * @param array $property |
||
| 28 | * |
||
| 29 | * @see http://developers.hubspot.com/docs/methods/companies/update_company_property |
||
| 30 | * |
||
| 31 | * @return \SevenShores\Hubspot\Http\Response |
||
| 32 | */ |
||
| 33 | function update($propertyName, $property) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * For a portal, delete an existing company property. |
||
| 45 | * @param string $propertyName The API name of the property that you will be deleting. |
||
| 46 | * |
||
| 47 | * @see http://developers.hubspot.com/docs/methods/companies/delete_company_property |
||
| 48 | * |
||
| 49 | * @return \SevenShores\Hubspot\Http\Response |
||
| 50 | */ |
||
| 51 | function delete($propertyName) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Returns a JSON object representing the definition for a given company property. |
||
| 60 | * @param string $propertyName The API name of the property that you wish to see metadata for. |
||
| 61 | * |
||
| 62 | * @see http://developers.hubspot.com/docs/methods/companies/get_company_property |
||
| 63 | * |
||
| 64 | * @return \SevenShores\Hubspot\Http\Response |
||
| 65 | */ |
||
| 66 | function get($propertyName) |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Returns all of the company properties, including their definition. |
||
| 75 | * |
||
| 76 | * @see http://developers.hubspot.com/docs/methods/companies/get_company_properties |
||
| 77 | * |
||
| 78 | * @return \SevenShores\Hubspot\Http\Response |
||
| 79 | */ |
||
| 80 | function all() |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Create a new company property group to gather like company-level data. |
||
| 89 | * @param array $group Defines the group and any properties within it. |
||
| 90 | * |
||
| 91 | * @see http://developers.hubspot.com/docs/methods/companies/create_company_property_group |
||
| 92 | * |
||
| 93 | * @return \SevenShores\Hubspot\Http\Response |
||
| 94 | */ |
||
| 95 | function createGroup($group) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Update a previously created company property group. |
||
| 106 | * @param string $groupName The API name of the property group that you will be updating. |
||
| 107 | * @param array $group Defines the property group and any properties within it. |
||
| 108 | * |
||
| 109 | * @see http://developers.hubspot.com/docs/methods/companies/update_company_property_group |
||
| 110 | * |
||
| 111 | * @return \SevenShores\Hubspot\Http\Response |
||
| 112 | */ |
||
| 113 | function updateGroup($groupName, $group) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Delete an existing company property group. |
||
| 125 | * @param string $groupName The API name of the property group that you will be deleting. |
||
| 126 | * |
||
| 127 | * @see http://developers.hubspot.com/docs/methods/companies/delete_company_property_group |
||
| 128 | * |
||
| 129 | * @return \SevenShores\Hubspot\Http\Response |
||
| 130 | */ |
||
| 131 | function deleteGroup($groupName) |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Returns all of the company property groups for a given portal. |
||
| 140 | * @param bool $includeProperties If true returns all of the properties for each company property group. |
||
| 141 | * |
||
| 142 | * @see http://developers.hubspot.com/docs/methods/companies/get_company_property_groups |
||
| 143 | * |
||
| 144 | * @return \SevenShores\Hubspot\Http\Response |
||
| 145 | */ |
||
| 146 | View Code Duplication | function getAllGroups($includeProperties = false) |
|
| 158 | } |
||
| 159 |
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.