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 Application extends \samsoncms\api\generator\analyzer\Virtual |
||
12 | { |
||
13 | /** @var string Metadata class */ |
||
14 | protected $metadataClass = \samsoncms\api\generator\metadata\Application::class; |
||
15 | |||
16 | /** |
||
17 | * Analyze entity. |
||
18 | * |
||
19 | * @param \samsoncms\api\generator\metadata\Virtual $metadata |
||
20 | * @param array $structureRow Entity database row |
||
21 | */ |
||
22 | View Code Duplication | public function analyzeEntityRecord(&$metadata, array $structureRow) |
|
35 | |||
36 | /** |
||
37 | * Virtual entity additional field analyzer. |
||
38 | * |
||
39 | * @param \samsoncms\api\generator\metadata\Virtual $metadata Metadata instance for filling |
||
40 | * @param int $fieldID Additional field identifier |
||
41 | * @param array $fieldRow Additional field database row |
||
42 | */ |
||
43 | View Code Duplication | public function analyzeFieldRecord(&$metadata, $fieldID, array $fieldRow) |
|
60 | } |
||
61 | //[PHPCOMPRESSOR(remove,end)] |
||
62 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.