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 namespace Davispeixoto\ForceDotComToolkitForPhp; |
||
| 35 | class SforcePartnerClient extends SforceBaseClient |
||
| 36 | { |
||
| 37 | const PARTNER_NAMESPACE = 'urn:partner.soap.sforce.com'; |
||
| 38 | |||
| 39 | function __construct() |
||
|
|
|||
| 40 | { |
||
| 41 | $this->namespace = self::PARTNER_NAMESPACE; |
||
| 42 | } |
||
| 43 | |||
| 44 | protected function getSoapClient($wsdl, $options) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Adds one or more new individual objects to your organization's data. |
||
| 51 | * @param array $sObjects Array of one or more sObjects (up to 200) to create. |
||
| 52 | * @return SaveResult |
||
| 53 | */ |
||
| 54 | View Code Duplication | public function create($sObjects) |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Merge records |
||
| 69 | * |
||
| 70 | * @param stdclass $mergeRequest |
||
| 71 | * @param String $type |
||
| 72 | * @return mixed |
||
| 73 | */ |
||
| 74 | public function merge($mergeRequest) |
||
| 86 | |||
| 87 | /** |
||
| 88 | * |
||
| 89 | * @param array $request |
||
| 90 | */ |
||
| 91 | View Code Duplication | public function sendSingleEmail($request) |
|
| 108 | |||
| 109 | /** |
||
| 110 | * |
||
| 111 | * @param array $request |
||
| 112 | */ |
||
| 113 | View Code Duplication | public function sendMassEmail($request) |
|
| 131 | |||
| 132 | /** |
||
| 133 | * Updates one or more new individual objects to your organization's data. |
||
| 134 | * @param array sObjects Array of sObjects |
||
| 135 | * @return UpdateResult |
||
| 136 | */ |
||
| 137 | View Code Duplication | public function update($sObjects) |
|
| 149 | |||
| 150 | /** |
||
| 151 | * Creates new objects and updates existing objects; uses a custom field to |
||
| 152 | * determine the presence of existing objects. In most cases, we recommend |
||
| 153 | * that you use upsert instead of create because upsert is idempotent. |
||
| 154 | * Available in the API version 7.0 and later. |
||
| 155 | * |
||
| 156 | * @param string $ext_Id External Id |
||
| 157 | * @param array $sObjects Array of sObjects |
||
| 158 | * @return UpsertResult |
||
| 159 | */ |
||
| 160 | public function upsert($ext_Id, $sObjects) |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @param string $fieldList |
||
| 176 | * @param string $sObjectType |
||
| 177 | * @param array $ids |
||
| 178 | * @return string |
||
| 179 | */ |
||
| 180 | public function retrieve($fieldList, $sObjectType, $ids) |
||
| 184 | |||
| 185 | /** |
||
| 186 | * |
||
| 187 | * @param mixed $response |
||
| 188 | * @return array |
||
| 189 | */ |
||
| 190 | private function _retrieveResult($response) |
||
| 205 | |||
| 206 | } |
||
| 207 |
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.