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 |
||
| 29 | class TemplateValues extends AbstractEntity implements TemplateValuesInterface |
||
|
|
|||
| 30 | { |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Qualification field of the job template |
||
| 34 | * |
||
| 35 | * @var String |
||
| 36 | * @ODM\String |
||
| 37 | */ |
||
| 38 | protected $qualifications=''; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Requirements field of the job template |
||
| 42 | * |
||
| 43 | * @var String |
||
| 44 | * @ODM\String |
||
| 45 | */ |
||
| 46 | protected $requirements=''; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Benefits field of the job template |
||
| 50 | * |
||
| 51 | * @var String |
||
| 52 | * @ODM\String |
||
| 53 | */ |
||
| 54 | protected $benefits=''; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Job title field of the job template |
||
| 58 | * |
||
| 59 | * @var String |
||
| 60 | * @ODM\String |
||
| 61 | */ |
||
| 62 | protected $title=''; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Company description field of the job template |
||
| 66 | * |
||
| 67 | * @var String |
||
| 68 | * @ODM\String |
||
| 69 | */ |
||
| 70 | protected $description=''; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * language of the job template values |
||
| 74 | * |
||
| 75 | * @var String |
||
| 76 | * @ODM\String |
||
| 77 | */ |
||
| 78 | protected $language=''; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * free values (currently not in use) |
||
| 82 | * |
||
| 83 | * @ODM\Hash |
||
| 84 | */ |
||
| 85 | protected $_freeValues; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Sets the Qualification field of the job template |
||
| 89 | * |
||
| 90 | * @param $qualifications |
||
| 91 | * @return $this |
||
| 92 | */ |
||
| 93 | public function setQualifications($qualifications) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Gets the qualification of a job template |
||
| 101 | * |
||
| 102 | * @return String |
||
| 103 | */ |
||
| 104 | public function getQualifications() |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Sets the requirements of a job template |
||
| 111 | * |
||
| 112 | * @param String $requirements |
||
| 113 | * @return $this |
||
| 114 | */ |
||
| 115 | public function setRequirements($requirements) |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Gets the requirements of a job template |
||
| 123 | * |
||
| 124 | * @return String |
||
| 125 | */ |
||
| 126 | public function getRequirements() |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Sets the benefits of a job template |
||
| 133 | * |
||
| 134 | * @param String $benefits |
||
| 135 | * @return $this |
||
| 136 | */ |
||
| 137 | public function setBenefits($benefits) |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Gets the Benefits of a job template |
||
| 145 | * |
||
| 146 | * @return String |
||
| 147 | */ |
||
| 148 | public function getBenefits() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Sets the job title of the job template |
||
| 155 | * |
||
| 156 | * @param $title |
||
| 157 | * @return $this |
||
| 158 | */ |
||
| 159 | public function setTitle($title) |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Gets the job title of the job template |
||
| 167 | * |
||
| 168 | * @return String |
||
| 169 | */ |
||
| 170 | public function getTitle() |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Sets the company description of the job template |
||
| 177 | * |
||
| 178 | * @param $description |
||
| 179 | * @return $this |
||
| 180 | */ |
||
| 181 | public function setDescription($description) |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Gets the company description of the job template |
||
| 189 | * |
||
| 190 | * @return String |
||
| 191 | */ |
||
| 192 | public function getDescription() |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Sets the language of the job template values |
||
| 199 | * |
||
| 200 | * @param $language |
||
| 201 | * @return $this |
||
| 202 | */ |
||
| 203 | public function setLanguage($language) |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Gets the language of the job template values |
||
| 211 | * |
||
| 212 | * @return String |
||
| 213 | */ |
||
| 214 | public function getLanguage() |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @param null $key |
||
| 221 | * @param null $default |
||
| 222 | * @param bool $set |
||
| 223 | * @return null |
||
| 224 | */ |
||
| 225 | View Code Duplication | public function get($key = null, $default = null, $set = false) |
|
| 235 | |||
| 236 | /** |
||
| 237 | * @param $key |
||
| 238 | * @param $value |
||
| 239 | * @return $this |
||
| 240 | */ |
||
| 241 | public function set($key, $value) |
||
| 247 | |||
| 248 | View Code Duplication | public function __get($property) |
|
| 261 | |||
| 262 | View Code Duplication | public function __set($property, $value) |
|
| 278 | |||
| 279 | View Code Duplication | public function __isset($property) |
|
| 291 | } |
||
| 292 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.