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