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 DealProperties extends Resource |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Get a Deal Property. |
||
| 10 | * |
||
| 11 | * Returns a JSON object representing the definition for a given deal property. |
||
| 12 | * |
||
| 13 | * @see http://developers.hubspot.com/docs/methods/deals/get_deal_property |
||
| 14 | * |
||
| 15 | * @param string $name The name of the property. |
||
| 16 | * @return \SevenShores\Hubspot\Http\Response |
||
| 17 | */ |
||
| 18 | function get($name) |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Create a deal property. |
||
| 27 | * |
||
| 28 | * Create a property on every deal object to store a specific piece of data. In the example below, |
||
| 29 | * we want to store an invoice number on a separate field on deals. |
||
| 30 | * |
||
| 31 | * @see https://developers.hubspot.com/docs/methods/deals/create_deal_property |
||
| 32 | * |
||
| 33 | * @param array $property |
||
| 34 | * @return \SevenShores\Hubspot\Http\Response |
||
| 35 | */ |
||
| 36 | function create($property) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Update a deal property. |
||
| 47 | * |
||
| 48 | * Update a specified deal property. |
||
| 49 | * |
||
| 50 | * @see http://developers.hubspot.com/docs/methods/deals/update_deal_property |
||
| 51 | * |
||
| 52 | * @param string $name |
||
| 53 | * @param array $property |
||
| 54 | * @return \SevenShores\Hubspot\Http\Response |
||
| 55 | */ |
||
| 56 | View Code Duplication | function update($name, $property) |
|
| 65 | |||
| 66 | } |
||
| 67 |
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.