Conditions | 1 |
Paths | 1 |
Total Lines | 84 |
Code Lines | 63 |
Lines | 22 |
Ratio | 26.19 % |
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 | Schema::create('User', function (Blueprint $table) { |
||
18 | $table->increments('id'); |
||
19 | $table->string('username', 25)->nullable()->unique(); |
||
20 | $table->string('password', 60)->nullable(); |
||
21 | $table->string('first_name', 25); |
||
22 | $table->string('last_name', 25); |
||
23 | $table->string('email')->unique(); |
||
24 | $table->text('description')->nullable(); |
||
25 | $table->timestamp('birthday')->nullable(); |
||
26 | $table->tinyInteger('status'); |
||
27 | $table->string('ip', 15); |
||
28 | $table->binary('staff'); |
||
29 | $table->timestamp('last_login')->nullable(); |
||
30 | $table->text('permissions')->nullable(); |
||
31 | $table->rememberToken(); |
||
32 | $table->timestamps(); |
||
33 | $table->softDeletes(); |
||
34 | $table->creation(); |
||
35 | }); |
||
36 | |||
37 | Schema::create('Logs', function (Blueprint $table) { |
||
38 | $table->increments('id'); |
||
39 | $table->text('log'); |
||
40 | $table->timestamps(); |
||
41 | $table->creation(); |
||
42 | }); |
||
43 | |||
44 | Schema::create('Settings', function (Blueprint $table) { |
||
45 | $table->increments('id'); |
||
46 | $table->string('friendy_name', 25); |
||
47 | $table->string('name', 25); |
||
48 | $table->string('vale', 150)->nullable(); |
||
49 | $table->string('description', 250)->nullable(); |
||
50 | $table->creation(); |
||
51 | }); |
||
52 | |||
53 | View Code Duplication | Schema::create('Group', function (Blueprint $table) { |
|
54 | $table->increments('id'); |
||
55 | $table->string('name', 25); |
||
56 | $table->string('description', 250)->nullable(); |
||
57 | $table->string('slug', 250); |
||
58 | $table->text('permissions')->nullable(); |
||
59 | |||
60 | $table->timestamps(); |
||
61 | $table->softDeletes(); |
||
62 | $table->creation(); |
||
63 | $table->unique('slug'); |
||
64 | }); |
||
65 | |||
66 | Schema::create('Group_User', function (Blueprint $table) { |
||
67 | $table->increments('id'); |
||
68 | $table->integer('user')->unsigned(); |
||
69 | $table->integer('group')->unsigned(); |
||
70 | |||
71 | $table->nullableTimestamps(); |
||
72 | $table->creation(); |
||
73 | |||
74 | $table->foreign('user')->references('id')->on('User'); |
||
75 | $table->foreign('group')->references('id')->on('Group'); |
||
76 | }); |
||
77 | |||
78 | View Code Duplication | Schema::create('ActivityFeed', function (Blueprint $table) { |
|
79 | $table->increments('id'); |
||
80 | $table->string('added_by', 150); |
||
81 | $table->text('activity'); |
||
82 | $table->string('icon', 100); |
||
83 | $table->timestamp('visibility'); |
||
84 | $table->string('link', 250)->nullable(); |
||
85 | $table->text('requirements')->nullable(); |
||
86 | $table->timestamps(); |
||
87 | }); |
||
88 | |||
89 | Schema::create('Permission', function (Blueprint $table) { |
||
90 | $table->increments('id'); |
||
91 | $table->string('key', 100); |
||
92 | $table->string('description', 250); |
||
93 | |||
94 | $table->unique('key'); |
||
95 | }); |
||
96 | |||
97 | } |
||
98 | |||
118 |
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.