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 |
||
11 | class ContainerVolumeEntity |
||
|
|||
12 | { |
||
13 | /** |
||
14 | * @param array|object $jobData |
||
15 | * @throws \InvalidArgumentException |
||
16 | */ |
||
17 | 6 | View Code Duplication | public function __construct($jobData = []) |
31 | |||
32 | public $unknown_fields = []; |
||
33 | |||
34 | /** @var string */ |
||
35 | public $containerPath = ''; |
||
36 | |||
37 | /** @var string */ |
||
38 | public $hostPath = ''; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | * |
||
43 | * read-write and read-only. |
||
44 | * val RW, RO = Value |
||
45 | */ |
||
46 | public $mode = ''; |
||
47 | } |
||
48 |
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
.