Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 40 |
Lines | 40 |
Ratio | 67.8 % |
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 |
||
14 | public function up() |
||
15 | { |
||
16 | |||
17 | View Code Duplication | Schema::create('Task', function (Blueprint $table) { |
|
18 | $table->increments('id'); |
||
19 | $table->string('title', 50); |
||
20 | $table->string('description', 250)->nullable(); |
||
21 | $table->tinyInteger('status'); |
||
22 | $table->timestamps(); |
||
23 | $table->softDeletes(); |
||
24 | }); |
||
25 | |||
26 | View Code Duplication | Schema::create('TaskList', function (Blueprint $table) { |
|
27 | $table->increments('id'); |
||
28 | $table->string('name', 50); |
||
29 | $table->string('description', 250)->nullable(); |
||
30 | $table->timestamps(); |
||
31 | $table->softDeletes(); |
||
32 | }); |
||
33 | |||
34 | View Code Duplication | Schema::create('Task_TaskList', function (Blueprint $table) { |
|
35 | $table->increments('id'); |
||
36 | $table->integer('task')->unsigned(); |
||
37 | $table->integer('tasklist')->unsigned(); |
||
38 | $table->integer('order'); |
||
39 | |||
40 | $table->foreign('task')->references('id')->on('Task'); |
||
41 | $table->foreign('tasklist')->references('id')->on('TaskList'); |
||
42 | }); |
||
43 | |||
44 | View Code Duplication | Schema::create('Task_User', function (Blueprint $table) { |
|
45 | $table->increments('id'); |
||
46 | $table->integer('task')->unsigned(); |
||
47 | $table->integer('user')->unsigned(); |
||
48 | |||
49 | $table->foreign('task')->references('id')->on('Task'); |
||
50 | $table->foreign('user')->references('id')->on('User'); |
||
51 | }); |
||
52 | |||
53 | View Code Duplication | Schema::create('TaskList_User', function (Blueprint $table) { |
|
54 | $table->increments('id'); |
||
55 | $table->integer('tasklist')->unsigned(); |
||
56 | $table->integer('user')->unsigned(); |
||
57 | |||
58 | $table->foreign('tasklist')->references('id')->on('TaskList'); |
||
59 | $table->foreign('user')->references('id')->on('User'); |
||
60 | }); |
||
61 | |||
62 | Schema::create('TaskLog', function (Blueprint $table) { |
||
63 | $table->increments('id'); |
||
64 | $table->integer('task')->unsigned(); |
||
65 | $table->tinyInteger('status'); |
||
66 | $table->timestamps(); |
||
67 | $table->softDeletes(); |
||
68 | |||
69 | $table->foreign('task')->references('id')->on('Task'); |
||
70 | }); |
||
71 | |||
72 | } |
||
73 | |||
92 |
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.