| Conditions | 8 | 
| Paths | 16 | 
| Total Lines | 54 | 
| Code Lines | 27 | 
| 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 namespace crocodicstudio\crudbooster\commands;  | 
            ||
| 38 |     private function generateSeeder() { | 
            ||
| 39 | set_time_limit(120);  | 
            ||
| 40 | $tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();  | 
            ||
| 41 | $php_string = "";  | 
            ||
| 42 |         $additional_tables = cbConfig("ADDITIONAL_DATA_MIGRATION"); | 
            ||
| 43 | |||
| 44 |         foreach($tables as $table) { | 
            ||
| 45 |             if(substr($table,0,3) == "cb_" || in_array($table, $additional_tables)) { | 
            ||
| 46 |                 $this->info("Create seeder for table : ".$table); | 
            ||
| 47 | $rows = DB::table($table)->get();  | 
            ||
| 48 | $data = [];  | 
            ||
| 49 |                 foreach($rows as $i=>$row) { | 
            ||
| 50 | $data[$i] = [];  | 
            ||
| 51 |                     foreach($row as $key=>$val) { | 
            ||
| 52 | $data[$i][$key] = $val;  | 
            ||
| 53 | }  | 
            ||
| 54 | }  | 
            ||
| 55 |                 if(count($data)!=0) { | 
            ||
| 56 | $php_string .= 'DB::table(\''.$table.'\')->delete();'."\n\t\t\t";  | 
            ||
| 57 |                     $php_string .= 'DB::table(\''.$table.'\')->insert('.min_var_export($data).');'."\n\t\t\t"; | 
            ||
| 58 | }  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | $seederFileTemplate = '  | 
            ||
| 62 | <?php  | 
            ||
| 63 | use Illuminate\Database\Seeder;  | 
            ||
| 64 | use Illuminate\Support\Facades\DB;  | 
            ||
| 65 | class CbMigrationSeeder extends Seeder  | 
            ||
| 66 | { | 
            ||
| 67 | public function run()  | 
            ||
| 68 |     { | 
            ||
| 69 | $this->command->info(\'Please wait updating the data...\');  | 
            ||
| 70 | $this->call(\'CbMigrationData\');  | 
            ||
| 71 | $this->command->info(\'Updating the data completed !\');  | 
            ||
| 72 | }  | 
            ||
| 73 | }  | 
            ||
| 74 | class CbMigrationData extends Seeder { | 
            ||
| 75 |     public function run() {         | 
            ||
| 76 | '.$php_string.'  | 
            ||
| 77 | }  | 
            ||
| 78 | }  | 
            ||
| 79 | ';  | 
            ||
| 80 |         file_put_contents(base_path('database/seeds/CbMigrationSeeder.php'), $seederFileTemplate); | 
            ||
| 81 | |||
| 82 | $composer_path = '';  | 
            ||
| 83 |         if (file_exists(getcwd().'/composer.phar')) { | 
            ||
| 84 | $composer_path = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';  | 
            ||
| 85 |         }else{ | 
            ||
| 86 | $composer_path = 'composer';  | 
            ||
| 87 | }  | 
            ||
| 88 | |||
| 89 |         $this->info('Dumping auto loads new file seeder !'); | 
            ||
| 90 | $process = new Process($composer_path.' dump-autoload');  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 91 | $process->setWorkingDirectory(base_path())->run();  | 
            ||
| 92 | |||
| 95 |