| Conditions | 4 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 26 |
| 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 |
||
| 41 | public function install(): bool |
||
| 42 | { |
||
| 43 | $this->require('illuminate/database "5.5.*"'); |
||
| 44 | $this->task( |
||
| 45 | 'Creating directories and files under database folder', |
||
| 46 | function () { |
||
| 47 | $this->files->makeDirectory(database_path('migrations'), 0755, true, true); |
||
| 48 | if (! $this->files->exists(database_path('database.sqlite'))) { |
||
| 49 | $this->files->put(database_path('database.sqlite'), ''); |
||
| 50 | } |
||
| 51 | $this->files->makeDirectory(database_path('seeds'), 0755, false, true); |
||
| 52 | if (! $this->files->exists(database_path('seeds').DIRECTORY_SEPARATOR.'DatabaseSeeder.php')) { |
||
| 53 | $this->files->copy( |
||
| 54 | __DIR__.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php', |
||
| 55 | database_path('seeds').DIRECTORY_SEPARATOR.'DatabaseSeeder.php' |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | return true; |
||
| 60 | } |
||
| 61 | ); |
||
| 62 | |||
| 63 | $this->task( |
||
| 64 | 'Creating default config', |
||
| 65 | function () { |
||
| 66 | if (! $this->files->exists(static::CONFIG_FILE)) { |
||
| 67 | $this->files->copy( |
||
| 68 | static::CONFIG_FILE, |
||
| 69 | config_path('database.php') |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | |||
| 73 | return true; |
||
| 74 | } |
||
| 75 | ); |
||
| 76 | |||
| 77 | $this->info('Usage:'); |
||
| 78 | $this->comment( |
||
| 79 | ' |
||
| 80 | |||
| 81 | $ php <your-application-name> make:migration create_users_table |
||
| 82 | $ php <your-application-name> migrate |
||
| 83 | |||
| 84 | use Illuminate\Support\Facades\DB; |
||
| 85 | |||
| 86 | DB::table(\'users\')->insert( |
||
| 87 | [\'email\' => \'[email protected]\'] |
||
| 88 | ); |
||
| 89 | |||
| 90 | $users = DB::table(\'users\')->get(); |
||
| 91 | |||
| 92 | dd($users); |
||
| 93 | |||
| 94 | ' |
||
| 95 | ); |
||
| 96 | |||
| 97 | return true; |
||
| 98 | } |
||
| 99 | } |
||
| 100 |