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 |
||
| 7 | class CreateTelescopeEntriesTable extends Migration |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The database schema. |
||
| 11 | * |
||
| 12 | * @var \Illuminate\Database\Schema\Builder |
||
| 13 | */ |
||
| 14 | protected $schema; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Create a new migration instance. |
||
| 18 | * |
||
| 19 | * @return void |
||
|
|
|||
| 20 | */ |
||
| 21 | public function __construct() |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Get the migration connection name. |
||
| 28 | * |
||
| 29 | * @return string|null |
||
| 30 | */ |
||
| 31 | public function getConnection() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Run the migrations. |
||
| 38 | * |
||
| 39 | * @return void |
||
| 40 | */ |
||
| 41 | public function up() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Reverse the migrations. |
||
| 78 | * |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | public function down() |
||
| 87 | } |
||
| 88 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.