| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 71 | 
| Code Lines | 50 | 
| Lines | 62 | 
| Ratio | 87.32 % | 
| 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 |         $config = config('laravel-permission.table_names'); | ||
| 16 | |||
| 17 | View Code Duplication |         Schema::create($config['roles'], function (Blueprint $table) { | |
| 18 |             $table->increments('id'); | ||
| 19 |             $table->string('name')->unique(); | ||
| 20 |             $table->string('display_name')->nullable(); | ||
| 21 |             $table->string('description')->nullable(); | ||
| 22 | $table->timestamps(); | ||
| 23 | }); | ||
| 24 | |||
| 25 | View Code Duplication |         Schema::create($config['permissions'], function (Blueprint $table) { | |
| 26 |             $table->increments('id'); | ||
| 27 |             $table->string('name')->unique(); | ||
| 28 |             $table->string('display_name')->nullable(); | ||
| 29 |             $table->string('description')->nullable(); | ||
| 30 | $table->timestamps(); | ||
| 31 | }); | ||
| 32 | |||
| 33 | View Code Duplication |         Schema::create($config['user_has_permissions'], function (Blueprint $table) use ($config) { | |
| 34 |             $table->integer('user_id')->unsigned(); | ||
| 35 |             $table->integer('permission_id')->unsigned(); | ||
| 36 | |||
| 37 |             $table->foreign('user_id') | ||
| 38 |                 ->references('id') | ||
| 39 | ->on($config['users']) | ||
| 40 |                 ->onDelete('cascade'); | ||
| 41 | |||
| 42 |             $table->foreign('permission_id') | ||
| 43 |                 ->references('id') | ||
| 44 | ->on($config['permissions']) | ||
| 45 |                 ->onDelete('cascade'); | ||
| 46 | |||
| 47 | $table->primary(['user_id', 'permission_id']); | ||
| 48 | }); | ||
| 49 | |||
| 50 | View Code Duplication |         Schema::create($config['user_has_roles'], function (Blueprint $table) use ($config) { | |
| 51 |             $table->integer('role_id')->unsigned(); | ||
| 52 |             $table->integer('user_id')->unsigned(); | ||
| 53 | |||
| 54 |             $table->foreign('role_id') | ||
| 55 |                 ->references('id') | ||
| 56 | ->on($config['roles']) | ||
| 57 |                 ->onDelete('cascade'); | ||
| 58 | |||
| 59 |             $table->foreign('user_id') | ||
| 60 |                 ->references('id') | ||
| 61 | ->on($config['users']) | ||
| 62 |                 ->onDelete('cascade'); | ||
| 63 | |||
| 64 | $table->primary(['role_id', 'user_id']); | ||
| 65 | }); | ||
| 66 | |||
| 67 | View Code Duplication |         Schema::create($config['role_has_permissions'], function (Blueprint $table) use ($config) { | |
| 68 |             $table->integer('permission_id')->unsigned(); | ||
| 69 |             $table->integer('role_id')->unsigned(); | ||
| 70 | |||
| 71 |             $table->foreign('permission_id') | ||
| 72 |                 ->references('id') | ||
| 73 | ->on($config['permissions']) | ||
| 74 |                 ->onDelete('cascade'); | ||
| 75 | |||
| 76 |             $table->foreign('role_id') | ||
| 77 |                 ->references('id') | ||
| 78 | ->on($config['roles']) | ||
| 79 |                 ->onDelete('cascade'); | ||
| 80 | |||
| 81 | $table->primary(['permission_id', 'role_id']); | ||
| 82 | }); | ||
| 83 | } | ||
| 84 | |||
| 101 | 
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.