| Conditions | 1 |
| Paths | 1 |
| Total Lines | 123 |
| Code Lines | 90 |
| Lines | 32 |
| Ratio | 26.02 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 2 |
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->string('pic')->nullable();
|
||
| 27 | $table->integer('gender');
|
||
| 28 | $table->tinyInteger('status');
|
||
| 29 | $table->string('ip', 15);
|
||
| 30 | $table->tinyInteger('staff');
|
||
| 31 | $table->tinyInteger('force_new_password');
|
||
| 32 | $table->timestamp('last_login')->nullable();
|
||
| 33 | $table->text('permissions')->nullable();
|
||
| 34 | $table->rememberToken(); |
||
| 35 | $table->timestamps(); |
||
| 36 | $table->softDeletes(); |
||
| 37 | $table->creation(); |
||
| 38 | }); |
||
| 39 | |||
| 40 | Schema::table('User', function (Blueprint $table) {
|
||
| 41 | $table->creationRelation(); |
||
| 42 | }); |
||
| 43 | |||
| 44 | Schema::create('Visits', function (Blueprint $table) {
|
||
| 45 | $table->increments('id');
|
||
| 46 | $table->string('url')->nullable();
|
||
| 47 | $table->string('ip', 15)->nullable();
|
||
| 48 | $table->string('browser')->nullable();
|
||
| 49 | $table->tinyInteger('checked');
|
||
| 50 | |||
| 51 | $table->string('isoCode')->nullable();
|
||
| 52 | $table->string('country')->nullable();
|
||
| 53 | $table->string('city')->nullable();
|
||
| 54 | $table->string('state')->nullable();
|
||
| 55 | $table->string('postal_code')->nullable();
|
||
| 56 | $table->string('lat')->nullable();
|
||
| 57 | $table->string('lon')->nullable();
|
||
| 58 | $table->string('timezone')->nullable();
|
||
| 59 | $table->string('continent')->nullable();
|
||
| 60 | $table->timestamps(); |
||
| 61 | }); |
||
| 62 | |||
| 63 | Schema::create('Logs', function (Blueprint $table) {
|
||
| 64 | $table->increments('id');
|
||
| 65 | $table->text('log');
|
||
| 66 | $table->integer('target')->nullable();
|
||
| 67 | $table->string('ip', 15)->nullable();
|
||
| 68 | $table->timestamps(); |
||
| 69 | $table->creation(); |
||
| 70 | }); |
||
| 71 | |||
| 72 | Schema::table('Logs', function (Blueprint $table) {
|
||
| 73 | $table->creationRelation(); |
||
| 74 | }); |
||
| 75 | |||
| 76 | View Code Duplication | Schema::create('Settings', function (Blueprint $table) {
|
|
| 77 | $table->increments('id');
|
||
| 78 | $table->string('friendly_name', 25);
|
||
| 79 | $table->string('name', 25);
|
||
| 80 | $table->string('value', 150)->nullable();
|
||
| 81 | $table->string('description', 250)->nullable();
|
||
| 82 | $table->timestamps(); |
||
| 83 | $table->creation(); |
||
| 84 | }); |
||
| 85 | |||
| 86 | Schema::table('Settings', function (Blueprint $table) {
|
||
| 87 | $table->creationRelation(); |
||
| 88 | }); |
||
| 89 | |||
| 90 | View Code Duplication | Schema::create('Group', function (Blueprint $table) {
|
|
| 91 | $table->increments('id');
|
||
| 92 | $table->string('name', 25);
|
||
| 93 | $table->string('description', 250)->nullable();
|
||
| 94 | $table->string('slug', 250);
|
||
| 95 | $table->text('permissions')->nullable();
|
||
| 96 | |||
| 97 | $table->timestamps(); |
||
| 98 | $table->softDeletes(); |
||
| 99 | $table->creation(); |
||
| 100 | |||
| 101 | $table->unique('slug');
|
||
| 102 | }); |
||
| 103 | |||
| 104 | Schema::table('Group', function (Blueprint $table) {
|
||
| 105 | $table->creationRelation(); |
||
| 106 | }); |
||
| 107 | |||
| 108 | Schema::create('Group_User', function (Blueprint $table) {
|
||
| 109 | $table->increments('id');
|
||
| 110 | $table->integer('user')->unsigned();
|
||
| 111 | $table->integer('group')->unsigned();
|
||
| 112 | |||
| 113 | $table->timestamps(); |
||
| 114 | $table->softDeletes(); |
||
| 115 | $table->creation(); |
||
| 116 | |||
| 117 | $table->foreign('user')->references('id')->on('User');
|
||
| 118 | $table->foreign('group')->references('id')->on('Group');
|
||
| 119 | }); |
||
| 120 | |||
| 121 | Schema::table('Group_User', function (Blueprint $table) {
|
||
| 122 | $table->creationRelation(); |
||
| 123 | }); |
||
| 124 | |||
| 125 | View Code Duplication | Schema::create('ActivityFeed', function (Blueprint $table) {
|
|
| 126 | $table->increments('id');
|
||
| 127 | $table->string('added_by', 150);
|
||
| 128 | $table->text('activity');
|
||
| 129 | $table->string('icon', 100);
|
||
| 130 | $table->string('link', 250)->nullable();
|
||
| 131 | $table->text('permissions')->nullable();
|
||
| 132 | |||
| 133 | $table->timestamps(); |
||
| 134 | }); |
||
| 135 | |||
| 136 | } |
||
| 137 | |||
| 157 |
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.