| Conditions | 4 |
| Paths | 3 |
| Total Lines | 159 |
| 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 |
||
| 16 | public function handle(Filesystem $files) { |
||
| 17 | $this->files = $files; |
||
| 18 | |||
| 19 | $tableNameArgument = $this->argument('table_name'); |
||
| 20 | $modelOption = $this->option('model-name'); |
||
| 21 | $controllerOption = $this->option('controller-name'); |
||
| 22 | $repositoryOption = $this->option('repository-name'); |
||
| 23 | $policyOption = $this->option('policy-name'); |
||
| 24 | $exportOption = $this->option('with-export'); |
||
| 25 | $withoutBulkOptions = $this->option('without-bulk'); |
||
| 26 | $force = $this->option('force'); |
||
| 27 | $template = $this->option('template'); |
||
| 28 | |||
| 29 | $this->call('jig:generate:model', [ |
||
| 30 | 'table_name' => $tableNameArgument, |
||
| 31 | 'class_name' => $modelOption, |
||
| 32 | '--force' => $force, |
||
| 33 | '--template' => $template, |
||
| 34 | ]); |
||
| 35 | |||
| 36 | /*$this->call('jig:generate:factory', [ |
||
| 37 | 'table_name' => $tableNameArgument, |
||
| 38 | '--model-name' => $modelOption, |
||
| 39 | '--seed' => $this->option('seed'), |
||
| 40 | ]);*/ |
||
| 41 | |||
| 42 | $this->call('jig:generate:request:index', [ |
||
| 43 | 'table_name' => $tableNameArgument, |
||
| 44 | '--model-name' => $modelOption, |
||
| 45 | '--force' => $force, |
||
| 46 | '--template' => $template, |
||
| 47 | ]); |
||
| 48 | |||
| 49 | $this->call('jig:generate:request:store', [ |
||
| 50 | 'table_name' => $tableNameArgument, |
||
| 51 | '--model-name' => $modelOption, |
||
| 52 | '--force' => $force, |
||
| 53 | '--template' => $template, |
||
| 54 | ]); |
||
| 55 | |||
| 56 | $this->call('jig:generate:request:update', [ |
||
| 57 | 'table_name' => $tableNameArgument, |
||
| 58 | '--model-name' => $modelOption, |
||
| 59 | '--force' => $force, |
||
| 60 | '--template' => $template, |
||
| 61 | ]); |
||
| 62 | |||
| 63 | $this->call('jig:generate:request:destroy', [ |
||
| 64 | 'table_name' => $tableNameArgument, |
||
| 65 | '--model-name' => $modelOption, |
||
| 66 | '--force' => $force, |
||
| 67 | ]); |
||
| 68 | |||
| 69 | $this->call('jig:generate:repository', [ |
||
| 70 | 'table_name' => $tableNameArgument, |
||
| 71 | 'class_name' => $repositoryOption, |
||
| 72 | '--model-name' => $modelOption, |
||
| 73 | '--force' => $force, |
||
| 74 | '--with-export' => $exportOption, |
||
| 75 | '--without-bulk' => $withoutBulkOptions, |
||
| 76 | '--template' => $template, |
||
| 77 | ]); |
||
| 78 | |||
| 79 | $this->call('jig:generate:api:controller', [ |
||
| 80 | 'table_name' => $tableNameArgument, |
||
| 81 | 'class_name' => $controllerOption, |
||
| 82 | '--model-name' => $modelOption, |
||
| 83 | '--force' => $force, |
||
| 84 | '--with-export' => $exportOption, |
||
| 85 | '--without-bulk' => $withoutBulkOptions, |
||
| 86 | '--template' => $template, |
||
| 87 | ]); |
||
| 88 | $this->call('jig:generate:controller', [ |
||
| 89 | 'table_name' => $tableNameArgument, |
||
| 90 | 'class_name' => $controllerOption, |
||
| 91 | '--model-name' => $modelOption, |
||
| 92 | '--force' => $force, |
||
| 93 | '--with-export' => $exportOption, |
||
| 94 | '--without-bulk' => $withoutBulkOptions, |
||
| 95 | '--template' => $template, |
||
| 96 | ]); |
||
| 97 | |||
| 98 | |||
| 99 | $this->call('jig:generate:routes', [ |
||
| 100 | 'table_name' => $tableNameArgument, |
||
| 101 | '--model-name' => $modelOption, |
||
| 102 | '--controller-name' => $controllerOption, |
||
| 103 | '--with-export' => $exportOption, |
||
| 104 | '--without-bulk' => $withoutBulkOptions, |
||
| 105 | '--template' => $template, |
||
| 106 | ]); |
||
| 107 | |||
| 108 | |||
| 109 | $this->call('jig:generate:api:routes', [ |
||
| 110 | 'table_name' => $tableNameArgument, |
||
| 111 | '--model-name' => $modelOption, |
||
| 112 | '--controller-name' => $controllerOption, |
||
| 113 | '--with-export' => $exportOption, |
||
| 114 | '--without-bulk' => $withoutBulkOptions, |
||
| 115 | '--template' => $template, |
||
| 116 | ]); |
||
| 117 | |||
| 118 | $this->call('jig:generate:index', [ |
||
| 119 | 'table_name' => $tableNameArgument, |
||
| 120 | '--model-name' => $modelOption, |
||
| 121 | '--force' => $force, |
||
| 122 | '--with-export' => $exportOption, |
||
| 123 | '--without-bulk' => $withoutBulkOptions, |
||
| 124 | '--template' => $template, |
||
| 125 | ]); |
||
| 126 | |||
| 127 | $this->call('jig:generate:form', [ |
||
| 128 | 'table_name' => $tableNameArgument, |
||
| 129 | '--model-name' => $modelOption, |
||
| 130 | '--force' => $force, |
||
| 131 | '--template' => $template, |
||
| 132 | ]); |
||
| 133 | |||
| 134 | /* |
||
| 135 | $this->call('jig:generate:lang', [ |
||
| 136 | 'table_name' => $tableNameArgument, |
||
| 137 | '--model-name' => $modelOption, |
||
| 138 | '--with-export' => $exportOption, |
||
| 139 | ]); |
||
| 140 | |||
| 141 | |||
| 142 | if($exportOption){ |
||
| 143 | $this->call('jig:generate:export', [ |
||
| 144 | 'table_name' => $tableNameArgument, |
||
| 145 | '--force' => $force, |
||
| 146 | ]); |
||
| 147 | } |
||
| 148 | |||
| 149 | */ |
||
| 150 | $this->call('jig:generate:policy', [ |
||
| 151 | 'table_name' => $tableNameArgument, |
||
| 152 | 'class_name' => $policyOption, |
||
| 153 | '--model-name' => $modelOption, |
||
| 154 | '--force' => $force, |
||
| 155 | '--with-export' => false, |
||
| 156 | '--without-bulk' => false, |
||
| 157 | '--template' => $template, |
||
| 158 | ]); |
||
| 159 | |||
| 160 | if ($this->shouldGeneratePermissionsMigration()) { |
||
| 161 | $this->call('jig:generate:permissions', [ |
||
| 162 | 'table_name' => $tableNameArgument, |
||
| 163 | '--model-name' => $modelOption, |
||
| 164 | '--force' => $force, |
||
| 165 | '--without-bulk' => $withoutBulkOptions, |
||
| 166 | ]); |
||
| 167 | |||
| 168 | if ($this->option('no-interaction') || $this->confirm('Do you want to attach generated permissions to the default role now?', true)) { |
||
| 169 | $this->call('migrate'); |
||
| 170 | } |
||
| 171 | } |
||
| 172 | |||
| 173 | $this->info('Generating whole admin CRUD module finished'); |
||
| 174 | } |
||
| 175 | |||
| 204 |