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 MigrateStatusCommand extends Command |
||
| 12 | { |
||
| 13 | use DatabaseAwareCommandTrait; |
||
| 14 | use MigrationAwareCommandTrait; |
||
| 15 | |||
| 16 | public static $name = 'migrate:status'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var Migrator |
||
| 20 | */ |
||
| 21 | protected $migrator; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $migrationsPath; |
||
| 27 | |||
| 28 | public function __construct( |
||
| 38 | |||
| 39 | public function run() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
| 57 | **/ |
||
| 58 | protected function echoMigrationTable($ran, $migrationFiles) |
||
| 84 | |||
| 85 | View Code Duplication | public static function register(Cli $cli) |
|
| 95 | } |
||
| 96 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.