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 | ||
| 9 | class SOAPModelAccess extends SapphireSoapServer | ||
|  | |||
| 10 | { | ||
| 11 | private static $methods = array( | ||
| 12 | 'getXML' => array( | ||
| 13 | 'class' => 'string', | ||
| 14 | 'id' => 'int', | ||
| 15 | 'relation' => 'string', | ||
| 16 | '_returns' => 'string', | ||
| 17 | ), | ||
| 18 | 'getJSON' => array( | ||
| 19 | 'class' => 'string', | ||
| 20 | 'id' => 'int', | ||
| 21 | 'relation' => 'string', | ||
| 22 | '_returns' => 'string', | ||
| 23 | ), | ||
| 24 | 'putXML' => array( | ||
| 25 | 'class' => 'string', | ||
| 26 | 'id' => 'int', | ||
| 27 | 'relation' => 'string', | ||
| 28 | 'data' => 'string', | ||
| 29 | 'username' => 'string', | ||
| 30 | 'password' => 'string', | ||
| 31 | '_returns' => 'boolean', | ||
| 32 | ), | ||
| 33 | 'putJSON' => array( | ||
| 34 | 'class' => 'string', | ||
| 35 | 'id' => 'int', | ||
| 36 | 'relation' => 'string', | ||
| 37 | '_returns' => 'boolean', | ||
| 38 | ), | ||
| 39 | ); | ||
| 40 | |||
| 41 | public function Link($action = null) | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Used to emulate RESTful GET requests with XML data. | ||
| 48 | * | ||
| 49 | * @param string $class | ||
| 50 | * @param Number $id | ||
| 51 | * @param string $relation Relation name | ||
| 52 | * | ||
| 53 | * @return string | ||
| 54 | */ | ||
| 55 | View Code Duplication | public function getXML($class, $id, $relation = false, $username = null, $password = null) | |
| 68 | |||
| 69 | /** | ||
| 70 | * Used to emulate RESTful GET requests with JSON data. | ||
| 71 | * | ||
| 72 | * @param string $class | ||
| 73 | * @param Number $id | ||
| 74 | * @param string $relation Relation name | ||
| 75 | * @param string $username | ||
| 76 | * @param string $password | ||
| 77 | * | ||
| 78 | * @return string | ||
| 79 | */ | ||
| 80 | View Code Duplication | public function getJSON($class, $id, $relation = false, $username = null, $password = null) | |
| 93 | |||
| 94 | /** | ||
| 95 | * Used to emulate RESTful POST and PUT requests with XML data. | ||
| 96 | * | ||
| 97 | * @param string $class | ||
| 98 | * @param Number $id | ||
| 99 | * @param string $relation Relation name | ||
| 100 | * @param array $data | ||
| 101 | * @param string $username | ||
| 102 | * @param string $password | ||
| 103 | * | ||
| 104 | * @return string | ||
| 105 | */ | ||
| 106 | View Code Duplication | public function putXML($class, $id = false, $relation = false, $data, $username = null, $password = null) | |
| 120 | |||
| 121 | /** | ||
| 122 | * Used to emulate RESTful POST and PUT requests with JSON data. | ||
| 123 | * | ||
| 124 | * @param string $class | ||
| 125 | * @param Number $id | ||
| 126 | * @param string $relation Relation name | ||
| 127 | * @param array $data | ||
| 128 | * @param string $username | ||
| 129 | * @param string $password | ||
| 130 | * | ||
| 131 | * @return string | ||
| 132 | */ | ||
| 133 | View Code Duplication | public function putJSON($class = false, $id = false, $relation = false, $data, $username = null, $password = null) | |
| 147 | |||
| 148 | /** | ||
| 149 | * Used to emulate RESTful DELETE requests. | ||
| 150 | * | ||
| 151 | * @param string $class | ||
| 152 | * @param Number $id | ||
| 153 | * @param string $relation Relation name | ||
| 154 | * @param string $username | ||
| 155 | * @param string $password | ||
| 156 | * | ||
| 157 | * @return string | ||
| 158 | */ | ||
| 159 | View Code Duplication | public function deleteXML($class, $id, $relation = false, $username = null, $password = null) | |
| 172 | |||
| 173 | /** | ||
| 174 | * Used to emulate RESTful DELETE requests. | ||
| 175 | * | ||
| 176 | * @param string $class | ||
| 177 | * @param Number $id | ||
| 178 | * @param string $relation Relation name | ||
| 179 | * @param string $username | ||
| 180 | * @param string $password | ||
| 181 | * | ||
| 182 | * @return string | ||
| 183 | */ | ||
| 184 | View Code Duplication | public function deleteJSON($class, $id, $relation = false, $username = null, $password = null) | |
| 197 | |||
| 198 | /** | ||
| 199 | * Faking an HTTP Basicauth login in the PHP environment | ||
| 200 | * that RestfulServer can pick up. | ||
| 201 | * | ||
| 202 | * @param string $username Username | ||
| 203 | * @param string $password Plaintext password | ||
| 204 | */ | ||
| 205 | protected function authenticate($username, $password) | ||
| 214 | |||
| 215 | /** | ||
| 216 | * @param string $class | ||
| 217 | * @param Number $id | ||
| 218 | * @param string $relation | ||
| 219 | * @param string $extension | ||
| 220 | * | ||
| 221 | * @return string | ||
| 222 | */ | ||
| 223 | protected function buildRestfulURL($class, $id, $relation, $extension) | ||
| 238 | |||
| 239 | /** | ||
| 240 | * @param SS_HTTPResponse $response | ||
| 241 | * | ||
| 242 | * @return string XML string containing the HTTP error message | ||
| 243 | */ | ||
| 244 | protected function getErrorMessage($response) | ||
| 248 | } | ||
| 249 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.