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 | View Code Duplication | class xsString extends xsAnySimpleType |
|
|
|||
31 | { |
||
32 | use LengthTrait; |
||
33 | |||
34 | /** |
||
35 | * Construct. |
||
36 | * |
||
37 | * @param string $value |
||
38 | */ |
||
39 | public function __construct($value) |
||
44 | |||
45 | protected function fixValue() |
||
49 | |||
50 | protected function isOK() |
||
59 | } |
||
60 |
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider
.