| Conditions | 10 | 
| Paths | 19 | 
| Total Lines | 79 | 
| Code Lines | 44 | 
| 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  | 
            ||
| 33 | public function handle()  | 
            ||
| 34 |     { | 
            ||
| 35 | $this->newLine();  | 
            ||
| 36 |         $this->info('Starting Tech Bench Restore'); | 
            ||
| 37 | |||
| 38 | // If there was not a filename supplied, give the choice of what file to restore  | 
            ||
| 39 |         if(is_null($this->argument('filename'))) | 
            ||
| 40 |         { | 
            ||
| 41 | if(!$this->assignBackupFile())  | 
            ||
| 42 |             { | 
            ||
| 43 | return 0;  | 
            ||
| 44 | }  | 
            ||
| 45 | }  | 
            ||
| 46 | else  | 
            ||
| 47 |         { | 
            ||
| 48 |             $this->filename = $this->argument('filename'); | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 | // Verify that the backup file exists  | 
            ||
| 52 |         if(!Storage::disk('backups')->exists($this->filename)) | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 53 |         { | 
            ||
| 54 |             $this->error('     The filename entered does not exist                                           '); | 
            ||
| 55 |             $this->error('                  Exiting...                                                       '); | 
            ||
| 56 | return 0;  | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 | // Verify a proper backup file  | 
            ||
| 60 | if(!$this->validateFile())  | 
            ||
| 61 |         { | 
            ||
| 62 |             $this->error('     The backup file specified is not a Tech Bench Backup                          '); | 
            ||
| 63 |             $this->error('                  Exiting...                                                       '); | 
            ||
| 64 | return 0;  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 | if(!$this->checkVersion())  | 
            ||
| 68 |         { | 
            ||
| 69 | $this->cleanup();  | 
            ||
| 70 | return 0;  | 
            ||
| 71 | }  | 
            ||
| 72 | |||
| 73 | // Verify that the user wants to run this process  | 
            ||
| 74 |         if(!$this->option('confirmed')) | 
            ||
| 75 |         { | 
            ||
| 76 |             $this->warn(' ___________________________________________________________________ '); | 
            ||
| 77 |             $this->warn('|                      IMPORTANT NOTE:                              |'); | 
            ||
| 78 |             $this->warn('|   ALL EXISTING DATA WILL BE ERASED AND REPLACED WITH THE BACKUP   |'); | 
            ||
| 79 |             $this->warn('|___________________________________________________________________|'); | 
            ||
| 80 |             $this->warn('                                                                     '); | 
            ||
| 81 | }  | 
            ||
| 82 | |||
| 83 |         if(!$this->option('confirmed') && !$this->confirm('Are you sure?')) | 
            ||
| 84 |         { | 
            ||
| 85 | $this->cleanup();  | 
            ||
| 86 |             $this->line('Operation Canceled'); | 
            ||
| 87 | return 0;  | 
            ||
| 88 | }  | 
            ||
| 89 | |||
| 90 | // Start the restore process  | 
            ||
| 91 |         Log::critical('Restoring backup from filename - '.$this->filename); | 
            ||
| 92 | $this->newLine();  | 
            ||
| 93 |         $this->warn('Restoring backup from filename - '.$this->filename); | 
            ||
| 94 | |||
| 95 |         $this->call('down'); | 
            ||
| 96 | $this->newLine();  | 
            ||
| 97 | if(!$this->loadDatabase())  | 
            ||
| 98 |         { | 
            ||
| 99 |             $this->error('     Unable to modify database structure                                             '); | 
            ||
| 100 |             $this->error('     Please verify that the database user in the .env file has write permissions     '); | 
            ||
| 101 |             $this->error('     Exiting....                                                                     '); | 
            ||
| 102 | $this->cleanup();  | 
            ||
| 103 | return 0;  | 
            ||
| 104 | }  | 
            ||
| 105 | $this->loadFiles();  | 
            ||
| 106 | |||
| 107 | // $this->cleanup();  | 
            ||
| 108 | $this->newLine();  | 
            ||
| 109 |         $this->info('Tech Bench has been restored'); | 
            ||
| 110 |         $this->call('up'); | 
            ||
| 111 | return 0;  | 
            ||
| 112 | }  | 
            ||
| 316 |