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 |
||
| 30 | class TemplateValues extends AbstractEntity implements TemplateValuesInterface |
||
|
|
|||
| 31 | { |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Qualification field of the job template |
||
| 35 | * |
||
| 36 | * @var String |
||
| 37 | * @ODM\Field(type="string") |
||
| 38 | */ |
||
| 39 | protected $qualifications=''; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Requirements field of the job template |
||
| 43 | * |
||
| 44 | * @var String |
||
| 45 | * @ODM\Field(type="string") |
||
| 46 | */ |
||
| 47 | protected $requirements=''; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Benefits field of the job template |
||
| 51 | * |
||
| 52 | * @var String |
||
| 53 | * @ODM\Field(type="string") |
||
| 54 | */ |
||
| 55 | protected $benefits=''; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Job title field of the job template |
||
| 59 | * |
||
| 60 | * @var String |
||
| 61 | * @ODM\Field(type="string") |
||
| 62 | */ |
||
| 63 | protected $title=''; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Company description field of the job template |
||
| 67 | * |
||
| 68 | * @var String |
||
| 69 | * @ODM\Field(type="string") |
||
| 70 | */ |
||
| 71 | protected $description=''; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * language of the job template values. Must be a valid ISO 639-1 code |
||
| 75 | * |
||
| 76 | * @var String |
||
| 77 | * @ODM\Field(type="string") |
||
| 78 | */ |
||
| 79 | protected $language='en'; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Pure HTML |
||
| 83 | * |
||
| 84 | * @ODM\Field(type="string") |
||
| 85 | * @var string |
||
| 86 | * @since 0.29 |
||
| 87 | */ |
||
| 88 | protected $html=''; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * free values (currently not in use) |
||
| 92 | * |
||
| 93 | * @ODM\Hash |
||
| 94 | */ |
||
| 95 | protected $_freeValues; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Sets the Qualification field of the job template |
||
| 99 | * |
||
| 100 | * @param $qualifications |
||
| 101 | * @return $this |
||
| 102 | */ |
||
| 103 | public function setQualifications($qualifications) |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Gets the qualification of a job template |
||
| 111 | * |
||
| 112 | * @return String |
||
| 113 | */ |
||
| 114 | public function getQualifications() |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Sets the requirements of a job template |
||
| 121 | * |
||
| 122 | * @param String $requirements |
||
| 123 | * @return $this |
||
| 124 | */ |
||
| 125 | public function setRequirements($requirements) |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Gets the requirements of a job template |
||
| 133 | * |
||
| 134 | * @return String |
||
| 135 | */ |
||
| 136 | public function getRequirements() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * Sets the benefits of a job template |
||
| 143 | * |
||
| 144 | * @param String $benefits |
||
| 145 | * @return $this |
||
| 146 | */ |
||
| 147 | public function setBenefits($benefits) |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Gets the Benefits of a job template |
||
| 155 | * |
||
| 156 | * @return String |
||
| 157 | */ |
||
| 158 | public function getBenefits() |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Sets the job title of the job template |
||
| 165 | * |
||
| 166 | * @param $title |
||
| 167 | * @return $this |
||
| 168 | */ |
||
| 169 | public function setTitle($title) |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Gets the job title of the job template |
||
| 177 | * |
||
| 178 | * @return String |
||
| 179 | */ |
||
| 180 | public function getTitle() |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Sets the company description of the job template |
||
| 187 | * |
||
| 188 | * @param $description |
||
| 189 | * @return $this |
||
| 190 | */ |
||
| 191 | public function setDescription($description) |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Gets the company description of the job template |
||
| 199 | * |
||
| 200 | * @return String |
||
| 201 | */ |
||
| 202 | public function getDescription() |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Sets the language of the job template values |
||
| 209 | * |
||
| 210 | * @param $language |
||
| 211 | * @return $this |
||
| 212 | */ |
||
| 213 | public function setLanguage($language) |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Gets the language of the job template values |
||
| 221 | * |
||
| 222 | * @return String |
||
| 223 | */ |
||
| 224 | public function getLanguage() |
||
| 228 | |||
| 229 | /** |
||
| 230 | * @param string $html |
||
| 231 | * |
||
| 232 | * @return self |
||
| 233 | * @since 0.29 |
||
| 234 | */ |
||
| 235 | public function setHtml($html) |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @return string |
||
| 244 | * @since 0.29 |
||
| 245 | */ |
||
| 246 | public function getHtml() |
||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | /** |
||
| 254 | * @param null $key |
||
| 255 | * @param null $default |
||
| 256 | * @param bool $set |
||
| 257 | * @return null |
||
| 258 | */ |
||
| 259 | View Code Duplication | public function get($key = null, $default = null, $set = false) |
|
| 269 | |||
| 270 | /** |
||
| 271 | * @param $key |
||
| 272 | * @param $value |
||
| 273 | * @return $this |
||
| 274 | */ |
||
| 275 | public function set($key, $value) |
||
| 281 | |||
| 282 | View Code Duplication | public function __get($property) |
|
| 295 | |||
| 296 | View Code Duplication | public function __set($property, $value) |
|
| 312 | |||
| 313 | View Code Duplication | public function __isset($property) |
|
| 325 | } |
||
| 326 |
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.