| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 41 |
| Lines | 24 |
| Ratio | 42.11 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 13 | public function up() |
||
| 14 | { |
||
| 15 | Schema::create(config('admin.database.users_table'), function (Blueprint $table) { |
||
| 16 | $table->increments('id'); |
||
| 17 | $table->string('username', 190)->unique(); |
||
| 18 | $table->string('password', 60); |
||
| 19 | $table->string('name'); |
||
| 20 | $table->string('remember_token', 100)->nullable(); |
||
| 21 | $table->timestamps(); |
||
| 22 | }); |
||
| 23 | |||
| 24 | View Code Duplication | Schema::create(config('admin.database.roles_table'), function (Blueprint $table) { |
|
| 25 | $table->increments('id'); |
||
| 26 | $table->string('name', 50)->unique(); |
||
| 27 | $table->string('slug', 50); |
||
| 28 | $table->timestamps(); |
||
| 29 | }); |
||
| 30 | |||
| 31 | View Code Duplication | Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) { |
|
| 32 | $table->increments('id'); |
||
| 33 | $table->string('name', 50)->unique(); |
||
| 34 | $table->string('slug', 50); |
||
| 35 | $table->timestamps(); |
||
| 36 | }); |
||
| 37 | |||
| 38 | Schema::create(config('admin.database.menu_table'), function (Blueprint $table) { |
||
| 39 | $table->increments('id'); |
||
| 40 | $table->integer('parent_id')->default(0); |
||
| 41 | $table->integer('order'); |
||
| 42 | $table->string('title', 50); |
||
| 43 | $table->string('icon', 50); |
||
| 44 | $table->string('uri', 50); |
||
| 45 | |||
| 46 | $table->timestamps(); |
||
| 47 | }); |
||
| 48 | |||
| 49 | View Code Duplication | Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) { |
|
| 50 | $table->integer('role_id'); |
||
| 51 | $table->integer('user_id'); |
||
| 52 | $table->index(['role_id', 'user_id']); |
||
| 53 | $table->timestamps(); |
||
| 54 | }); |
||
| 55 | |||
| 56 | View Code Duplication | Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) { |
|
| 57 | $table->integer('role_id'); |
||
| 58 | $table->integer('permission_id'); |
||
| 59 | $table->index(['role_id', 'permission_id']); |
||
| 60 | $table->timestamps(); |
||
| 61 | }); |
||
| 62 | |||
| 63 | Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) { |
||
| 64 | $table->integer('role_id'); |
||
| 65 | $table->integer('menu_id'); |
||
| 66 | $table->index(['role_id', 'menu_id']); |
||
| 67 | $table->timestamps(); |
||
| 68 | }); |
||
| 69 | } |
||
| 70 | |||
| 87 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.