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 |
||
10 | class BrowserConsoleLoggerServiceProvider implements ServiceProviderInterface |
||
11 | { |
||
12 | |||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | public $loglevel = Logger::INFO; |
||
18 | |||
19 | |||
20 | /** |
||
21 | * @param int|null $loglevel Optional: Monolog Loglevel constant. Set to `null` to disable browser logging entirely. |
||
22 | */ |
||
23 | 2 | public function __construct(int $loglevel = null) |
|
27 | |||
28 | |||
29 | /** |
||
30 | * @param Container $dic [description] |
||
31 | * @return void |
||
32 | */ |
||
33 | 2 | View Code Duplication | public function register(Container $dic) |
66 | } |
||
67 |
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.