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 FetchEntity |
||
|
|
|||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param array|object $jobData |
||
| 15 | * @throws \InvalidArgumentException |
||
| 16 | */ |
||
| 17 | 2 | View Code Duplication | public function __construct($jobData = []) |
| 31 | |||
| 32 | public $unknown_fields = []; |
||
| 33 | |||
| 34 | /** @var string */ |
||
| 35 | public $uri = ""; |
||
| 36 | |||
| 37 | /** @var string */ |
||
| 38 | public $destPath = ''; |
||
| 39 | |||
| 40 | /** @var bool */ |
||
| 41 | public $extract = false; |
||
| 42 | |||
| 43 | /** @var bool */ |
||
| 44 | public $cache = false; |
||
| 45 | |||
| 46 | /** @var bool */ |
||
| 47 | public $executable = false; |
||
| 48 | } |
||
| 49 |
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.