| Conditions | 5 |
| Paths | 8 |
| Total Lines | 62 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 19 | public function up() |
||
| 20 | { |
||
| 21 | $connection = config('trans-helper.database.connection') ?: config('database.default'); |
||
| 22 | if (!Schema::connection($connection)->hasTable('_trans_helper_cites')) { |
||
| 23 | Schema::connection($connection)->create( |
||
| 24 | '_trans_helper_cites', |
||
| 25 | function (Blueprint $table) { |
||
| 26 | $table->bigIncrements('id'); |
||
| 27 | $table->string('file', 256)->default(''); |
||
| 28 | $table->unsignedBigInteger('line'); |
||
| 29 | $table->string('class', 256)->nullable(); |
||
| 30 | $table->string('function', 256)->nullable(); |
||
| 31 | $table->mediumText('code')->nullable(); |
||
| 32 | $table->timestamps(); |
||
| 33 | |||
| 34 | $table->index('created_at', 'created_at'); |
||
| 35 | $table->index('updated_at', 'updated_at'); |
||
| 36 | $table->index('function', 'function'); |
||
| 37 | $table->index('file', 'file'); |
||
| 38 | $table->index('line', 'line'); |
||
| 39 | $table->index('class', 'class'); |
||
| 40 | } |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | if (!Schema::connection($connection)->hasTable('_trans_helper_terms')) { |
||
| 45 | Schema::connection($connection)->create( |
||
| 46 | '_trans_helper_terms', |
||
| 47 | function (Blueprint $table) { |
||
| 48 | $table->bigIncrements('id'); |
||
| 49 | $table->string('namespace', 256)->default(''); |
||
| 50 | $table->string('term', 256)->default(''); |
||
| 51 | $table->json('translation')->nullable(); |
||
| 52 | $table->timestamps(); |
||
| 53 | |||
| 54 | $table->unique(['namespace', 'term'], 'unique_namespace_term'); |
||
| 55 | $table->index('namespace', 'namespace'); |
||
| 56 | $table->index('term', 'term'); |
||
| 57 | $table->index('created_at', 'created_at'); |
||
| 58 | $table->index('updated_at', 'updated_at'); |
||
| 59 | } |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | |||
| 63 | if (!Schema::connection($connection)->hasTable('_trans_helper_links')) { |
||
| 64 | Schema::connection($connection)->create( |
||
| 65 | '_trans_helper_links', |
||
| 66 | function (Blueprint $table) { |
||
| 67 | $table->unsignedBigInteger('cited'); |
||
| 68 | $table->unsignedBigInteger('vocab'); |
||
| 69 | |||
| 70 | $table->primary(['cited', 'vocab']); |
||
| 71 | $table->index('cited', 'cited'); |
||
| 72 | $table->index('vocab', 'vocab'); |
||
| 73 | $table->foreign('cited') |
||
| 74 | ->references('id') |
||
| 75 | ->on('_trans_helper_cites') |
||
| 76 | ->onDelete('cascade'); |
||
| 77 | $table->foreign('vocab') |
||
| 78 | ->references('id') |
||
| 79 | ->on('_trans_helper_terms') |
||
| 80 | ->onDelete('cascade'); |
||
| 81 | } |
||
| 99 |