| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| 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 |
||
| 25 | public function up() |
||
| 26 | { |
||
| 27 | Schema::create( |
||
| 28 | 'contents', |
||
| 29 | function (Blueprint $table) { |
||
| 30 | $table->increments('id'); |
||
| 31 | $table->timestamps(); |
||
| 32 | } |
||
| 33 | ); |
||
| 34 | |||
| 35 | Schema::create( |
||
| 36 | 'revisions', |
||
| 37 | function (Blueprint $table) { |
||
| 38 | $table->increments('id'); |
||
| 39 | $table->unsignedInteger('language_id'); |
||
| 40 | $table->unsignedInteger('content_id'); |
||
| 41 | $table->timestamps(); |
||
| 42 | |||
| 43 | $table->foreign('language_id')->references('id')->on('languages'); |
||
| 44 | $table->foreign('content_id')->references('id')->on('contents'); |
||
| 45 | } |
||
| 46 | ); |
||
| 47 | |||
| 48 | Schema::create( |
||
| 49 | 'field_string', |
||
| 50 | function (Blueprint $table) { |
||
| 51 | $this->fieldTableFields($table); |
||
| 52 | $table->string('value'); |
||
| 53 | } |
||
| 54 | ); |
||
| 55 | |||
| 56 | Schema::create( |
||
| 57 | 'field_text', |
||
| 58 | function (Blueprint $table) { |
||
| 59 | $this->fieldTableFields($table); |
||
| 60 | $table->text('value'); |
||
| 61 | } |
||
| 62 | ); |
||
| 63 | |||
| 64 | Schema::create( |
||
| 65 | 'field_date', |
||
| 66 | function (Blueprint $table) { |
||
| 67 | $this->fieldTableFields($table); |
||
| 68 | $table->date('value'); |
||
| 69 | } |
||
| 70 | ); |
||
| 71 | |||
| 72 | Schema::create( |
||
| 73 | 'field_datetime', |
||
| 74 | function (Blueprint $table) { |
||
| 75 | $this->fieldTableFields($table); |
||
| 76 | $table->datetime('value'); |
||
| 77 | } |
||
| 78 | ); |
||
| 79 | |||
| 80 | Schema::create( |
||
| 81 | 'field_entity', |
||
| 82 | function (Blueprint $table) { |
||
| 83 | $this->fieldTableFields($table); |
||
| 84 | $table->unsignedInteger('value'); |
||
| 85 | $table->foreign('value')->references('id')->on('contents'); |
||
| 86 | } |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | |||
| 106 |