error("The [$handlerPath] file could not be found."); exit; } $handlerFile = File::get($handlerPath); $find = 'use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;'; $replace = 'use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;'; if (\strpos($handlerFile, $replace) !== false) { $this->error('Exception handler seems to already be removed'); exit; } if (\strpos($handlerFile, $find) === false) { $this->error('Exception handler could not be removed, cannot find str to replace'); exit; } $handlerFile = \str_replace($find, $replace, $handlerFile); File::put($handlerPath, $handlerFile); $source = \config_path('exception-handler.php'); $sourceExist = File::exists($source); if ( $sourceExist and $this->ask('Remove config/exception-handler.php ? [y/n]') === 'y' ) { File::delete($source); } $this->info('Exception handler was successfully removed'); } }