| Conditions | 1 |
| Paths | 1 |
| Total Lines | 72 |
| Code Lines | 52 |
| 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 |
||
| 13 | public function up() |
||
| 14 | { |
||
| 15 | Schema::create('category', function (Blueprint $table) { |
||
| 16 | $table->increments('id'); |
||
| 17 | $table->string('name'); |
||
| 18 | $table->string('alias')->default(''); |
||
| 19 | $table->string('gender')->nullable(); |
||
| 20 | $table->integer('isTeam')->unsigned()->default(0); |
||
| 21 | $table->integer('ageCategory')->unsigned()->default(0); // 0 = none, 1 = child, 2= teenager, 3 = adult, 4 = master |
||
| 22 | $table->integer('ageMin')->unsigned()->default(0); |
||
| 23 | $table->integer('ageMax')->unsigned()->default(0); |
||
| 24 | $table->integer('gradeCategory')->unsigned()->default(0); |
||
| 25 | $table->integer('gradeMin')->unsigned()->default(0); |
||
| 26 | $table->integer('gradeMax')->unsigned()->default(0); |
||
| 27 | // $table->foreign('gradeMin') |
||
| 28 | // ->references('id') |
||
| 29 | // ->on('grade'); |
||
| 30 | // $table->foreign('gradeMax') |
||
| 31 | // ->references('id') |
||
| 32 | // ->on('grade'); |
||
| 33 | $table->unique(['name', 'alias', 'gender', 'isTeam', 'ageCategory', 'ageMin', 'ageMax', 'gradeCategory', 'gradeMin', 'gradeMax'], 'category_fields_unique'); |
||
| 34 | $table->timestamps(); |
||
| 35 | $table->engine = 'InnoDB'; |
||
| 36 | }); |
||
| 37 | |||
| 38 | Schema::create('championship', function (Blueprint $table) { |
||
| 39 | $table->increments('id'); |
||
| 40 | $table->integer('tournament_id')->unsigned()->index(); |
||
| 41 | $table->integer('category_id')->unsigned()->index(); |
||
| 42 | $table->unique(['tournament_id', 'category_id']); |
||
| 43 | |||
| 44 | $table->foreign('tournament_id') |
||
| 45 | ->references('id') |
||
| 46 | ->on('tournament') |
||
| 47 | ->onUpdate('cascade') |
||
| 48 | ->onDelete('cascade'); |
||
| 49 | |||
| 50 | $table->foreign('category_id') |
||
| 51 | ->references('id') |
||
| 52 | ->on('category') |
||
| 53 | ->onDelete('cascade'); |
||
| 54 | |||
| 55 | $table->timestamps(); |
||
| 56 | $table->softDeletes(); |
||
| 57 | $table->engine = 'InnoDB'; |
||
| 58 | }); |
||
| 59 | |||
| 60 | Schema::create('competitor', function (Blueprint $table) { |
||
| 61 | $table->increments('id'); |
||
| 62 | $table->integer('championship_id')->unsigned()->index(); |
||
| 63 | $table->foreign('championship_id') |
||
| 64 | ->references('id') |
||
| 65 | ->on('championship') |
||
| 66 | ->onUpdate('cascade') |
||
| 67 | ->onDelete('cascade'); |
||
| 68 | |||
| 69 | $table->integer('user_id')->unsigned()->index(); |
||
| 70 | $table->foreign('user_id') |
||
| 71 | ->references('id') |
||
| 72 | ->on('users') |
||
| 73 | ->onUpdate('cascade') |
||
| 74 | ->onDelete('cascade'); |
||
| 75 | |||
| 76 | $table->unique(['championship_id', 'user_id']); |
||
| 77 | |||
| 78 | $table->boolean('confirmed'); |
||
| 79 | |||
| 80 | $table->timestamps(); |
||
| 81 | $table->softDeletes(); |
||
| 82 | $table->engine = 'InnoDB'; |
||
| 83 | }); |
||
| 84 | } |
||
| 85 | |||
| 100 |
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.