| Conditions | 1 |
| Paths | 1 |
| Total Lines | 88 |
| Lines | 32 |
| Ratio | 36.36 % |
| 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('plans', function(Blueprint $table) { |
||
| 17 | $table->engine = 'InnoDB'; |
||
| 18 | |||
| 19 | $table->increments('id'); |
||
| 20 | $table->string('name'); |
||
| 21 | $table->text('description')->nullable(); |
||
| 22 | $table->string('group', 100)->nullable(); |
||
| 23 | $table->integer('free_days')->default(0); |
||
| 24 | $table->tinyInteger('sort_order'); |
||
| 25 | $table->boolean('is_active')->default(0); |
||
| 26 | $table->boolean('is_default')->default(0); |
||
| 27 | |||
| 28 | $table->timestamps(); |
||
| 29 | |||
| 30 | }); |
||
| 31 | |||
| 32 | Schema::create('plan_prices', function(Blueprint $table) { |
||
| 33 | $table->engine = 'InnoDB'; |
||
| 34 | |||
| 35 | $table->increments('id'); |
||
| 36 | $table->integer('plan_id')->unsigned(); |
||
| 37 | $table->decimal('amount'); |
||
| 38 | $table->enum('interval', ['day', 'month', 'year'])->nullable(); |
||
| 39 | $table->integer('interval_unit'); |
||
| 40 | |||
| 41 | $table->foreign('plan_id') |
||
|
|
|||
| 42 | ->references('id')->on('plans'); |
||
| 43 | |||
| 44 | $table->timestamps(); |
||
| 45 | |||
| 46 | }); |
||
| 47 | |||
| 48 | View Code Duplication | Schema::create('plan_features', function(Blueprint $table) { |
|
| 49 | $table->engine = 'InnoDB'; |
||
| 50 | |||
| 51 | $table->increments('id'); |
||
| 52 | $table->integer('plan_id')->unsigned(); |
||
| 53 | $table->string('code', 100); |
||
| 54 | $table->integer('value')->default(0); |
||
| 55 | $table->integer('sort_order'); |
||
| 56 | $table->boolean('is_consumable')->default(0); |
||
| 57 | |||
| 58 | $table->foreign('plan_id') |
||
| 59 | ->references('id')->on('plans'); |
||
| 60 | |||
| 61 | $table->timestamps(); |
||
| 62 | |||
| 63 | }); |
||
| 64 | |||
| 65 | Schema::create('subscriptions', function(Blueprint $table) { |
||
| 66 | $table->engine = 'InnoDB'; |
||
| 67 | |||
| 68 | $table->increments('id'); |
||
| 69 | $table->integer('plan_id')->unsigned(); |
||
| 70 | $table->string('subscriber_type')->nullable(); |
||
| 71 | $table->timestamp('subscriber_id')->nullable(); |
||
| 72 | $table->timestamp('start_at')->nullable(); |
||
| 73 | $table->timestamp('end_at')->nullable(); |
||
| 74 | $table->timestamp('cancelled_at')->nullable(); |
||
| 75 | $table->timestamp('upgrade_at')->nullable(); |
||
| 76 | $table->timestamp('downgrade_at')->nullable(); |
||
| 77 | |||
| 78 | $table->foreign('plan_id') |
||
| 79 | ->references('id')->on('plans'); |
||
| 80 | |||
| 81 | $table->timestamps(); |
||
| 82 | |||
| 83 | }); |
||
| 84 | |||
| 85 | View Code Duplication | Schema::create('subscriber_consumables', function(Blueprint $table) { |
|
| 86 | $table->engine = 'InnoDB'; |
||
| 87 | |||
| 88 | $table->increments('id'); |
||
| 89 | $table->integer('plan_feature_id')->unsigned(); |
||
| 90 | $table->string('subscriber_type'); |
||
| 91 | $table->integer('subscriber_id'); |
||
| 92 | $table->integer('available')->nullable(); |
||
| 93 | $table->integer('used')->nullable(); |
||
| 94 | |||
| 95 | $table->foreign('plan_feature_id') |
||
| 96 | ->references('id')->on('plans_features'); |
||
| 97 | |||
| 98 | $table->timestamps(); |
||
| 99 | |||
| 100 | }); |
||
| 101 | } |
||
| 102 | |||
| 117 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: