| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 59 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 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  | 
            ||
| 9 | public function up()  | 
            ||
| 10 |     { | 
            ||
| 11 |         $tableNames = config('permission.table_names'); | 
            ||
| 12 | |||
| 13 |         Schema::create($tableNames['permissions'], function (Blueprint $table) { | 
            ||
| 14 |             $table->increments('id'); | 
            ||
| 15 |             $table->string('name'); | 
            ||
| 16 |             $table->string('guard_name'); | 
            ||
| 17 | $table->timestamps();  | 
            ||
| 18 | });  | 
            ||
| 19 | |||
| 20 |         Schema::create($tableNames['roles'], function (Blueprint $table) { | 
            ||
| 21 |             $table->increments('id'); | 
            ||
| 22 |             $table->string('name'); | 
            ||
| 23 |             $table->string('guard_name'); | 
            ||
| 24 | $table->timestamps();  | 
            ||
| 25 | });  | 
            ||
| 26 | |||
| 27 |         Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames) { | 
            ||
| 28 |             $table->unsignedInteger('permission_id'); | 
            ||
| 29 |             $table->morphs('model'); | 
            ||
| 30 | |||
| 31 |             $table->foreign('permission_id') | 
            ||
| 32 |                 ->references('id') | 
            ||
| 33 | ->on($tableNames['permissions'])  | 
            ||
| 34 |                 ->onDelete('cascade'); | 
            ||
| 35 | |||
| 36 | $table->primary(['permission_id', 'model_id', 'model_type']);  | 
            ||
| 37 | });  | 
            ||
| 38 | |||
| 39 |         Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames) { | 
            ||
| 40 |             $table->unsignedInteger('role_id'); | 
            ||
| 41 |             $table->morphs('model'); | 
            ||
| 42 | |||
| 43 |             $table->foreign('role_id') | 
            ||
| 44 |                 ->references('id') | 
            ||
| 45 | ->on($tableNames['roles'])  | 
            ||
| 46 |                 ->onDelete('cascade'); | 
            ||
| 47 | |||
| 48 | $table->primary(['role_id', 'model_id', 'model_type']);  | 
            ||
| 49 | });  | 
            ||
| 50 | |||
| 51 |         Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { | 
            ||
| 52 |             $table->unsignedInteger('permission_id'); | 
            ||
| 53 |             $table->unsignedInteger('role_id'); | 
            ||
| 54 | |||
| 55 |             $table->foreign('permission_id') | 
            ||
| 56 |                 ->references('id') | 
            ||
| 57 | ->on($tableNames['permissions'])  | 
            ||
| 58 |                 ->onDelete('cascade'); | 
            ||
| 59 | |||
| 60 |             $table->foreign('role_id') | 
            ||
| 61 |                 ->references('id') | 
            ||
| 62 | ->on($tableNames['roles'])  | 
            ||
| 63 |                 ->onDelete('cascade'); | 
            ||
| 64 | |||
| 65 | $table->primary(['permission_id', 'role_id']);  | 
            ||
| 66 | |||
| 67 |             app('cache')->forget('spatie.permission.cache'); | 
            ||
| 68 | });  | 
            ||
| 82 |