We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 16 | public function up() |
||
| 17 | { |
||
| 18 | $plugin = new \App\Model\Plugin(); |
||
| 19 | |||
| 20 | $plugin->setAttribute('name', 'newsletters'); |
||
| 21 | $plugin->setAttribute('enabled', false); |
||
| 22 | $plugin->setAttribute('is_frontend', true); |
||
| 23 | $plugin->setAttribute('is_backend', true); |
||
| 24 | $plugin->setAttribute('required', false); |
||
| 25 | $plugin->save(); |
||
| 26 | |||
| 27 | Schema::create('newsletters', function (Blueprint $table) { |
||
| 28 | $table->increments('id'); |
||
| 29 | $table->string('title'); |
||
| 30 | $table->string('content'); |
||
| 31 | $table->integer('emailCount'); |
||
| 32 | $table->boolean('deliveryStatus'); |
||
| 33 | $table->integer('editor_id'); |
||
| 34 | $table->integer('creator_id'); |
||
| 35 | $table->timestamps(); |
||
| 36 | }); |
||
| 37 | |||
| 38 | Schema::create('newsletter_users', function (Blueprint $table) { |
||
| 39 | $table->increments('id'); |
||
| 40 | $table->string('email', 191)->unique(); |
||
| 41 | $table->timestamps(); |
||
| 42 | }); |
||
| 43 | |||
| 44 | Schema::create('newsletter_templates', function (Blueprint $table) { |
||
| 45 | $table->increments('id'); |
||
| 46 | $table->integer('editor_id'); |
||
| 47 | $table->integer('creator_id'); |
||
| 48 | $table->softDeletes(); |
||
| 49 | $table->timestamps(); |
||
| 50 | }); |
||
| 51 | |||
| 52 | Schema::table('pages', function (Blueprint $table) { |
||
| 53 | $table->string('identifier')->nullable()->after('id')->index(); |
||
| 54 | $table->boolean('special')->default(0)->after('editable'); |
||
| 55 | }); |
||
| 56 | |||
| 57 | /** @var Page $page */ |
||
| 58 | $page = app(Page::class); |
||
| 59 | $page->setAttribute('identifier', Newsletter::VIEW_NEWSLETTER_SUCCESS); |
||
| 60 | $page->setAttribute('title', 'Thank You Newsletter'); |
||
| 61 | $page->setAttribute('content', '<h1>Newsletter Signup Complete</h1> <p>Thank you for subscribing to our newsletter.</p>'); |
||
| 62 | $page->setAttribute('editable', true); |
||
| 63 | $page->setAttribute('special', true); |
||
| 64 | $page->setAttribute('sitemap', false); |
||
| 65 | $page->setAttribute('enabled', true); |
||
| 66 | $page->save(); |
||
| 67 | } |
||
| 79 |
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.