Code Duplication    Length = 41-42 lines in 2 locations

src/Command/ConvertCommand.php 1 location

@@ 66-106 (lines=41) @@
63
     *
64
     * @return int
65
     */
66
    protected function execute(InputInterface $input, OutputInterface $output) : int
67
    {
68
        $logger = LoggerHelper::createDefaultLogger($output);
69
70
        /** @var string $cacheOption */
71
        $cacheOption = $input->getOption('cache');
72
        $fileCache = new FilesystemCache($cacheOption);
73
        $cache = new SimpleCacheAdapter($fileCache);
74
75
        $logger->info('initializing converting process');
76
77
        $browscap = new BrowscapUpdater($cache, $logger);
78
79
        $logger->info('started converting local file');
80
81
        /** @var string $file */
82
        $file = $input->getArgument('file');
83
        if (! $file) {
84
            $file = $this->defaultIniFile;
85
        }
86
87
        try {
88
            $browscap->convertFile($file);
89
        } catch (Exception\FileNameMissingException $e) {
90
            $logger->debug($e);
91
92
            return 6;
93
        } catch (Exception\FileNotFoundException $e) {
94
            $logger->debug($e);
95
96
            return 7;
97
        } catch (Exception\ErrorReadingFileException $e) {
98
            $logger->debug($e);
99
100
            return 8;
101
        }
102
103
        $logger->info('finished converting local file');
104
105
        return 0;
106
    }
107
}
108

src/Command/FetchCommand.php 1 location

@@ 77-118 (lines=42) @@
74
     *
75
     * @return int
76
     */
77
    protected function execute(InputInterface $input, OutputInterface $output) : int
78
    {
79
        $logger = LoggerHelper::createDefaultLogger($output);
80
81
        /** @var string $cacheOption */
82
        $cacheOption = $input->getOption('cache');
83
        $fileCache = new FilesystemCache($cacheOption);
84
        $cache = new SimpleCacheAdapter($fileCache);
85
86
        /** @var string $file */
87
        $file = $input->getArgument('file');
88
        if (! $file) {
89
            $file = $this->defaultIniFile;
90
        }
91
92
        $logger->info('started fetching remote file');
93
94
        $browscap = new BrowscapUpdater($cache, $logger);
95
96
        /** @var string $remoteFileOption */
97
        $remoteFileOption = $input->getOption('remote-file');
98
99
        try {
100
            $browscap->fetch($file, $remoteFileOption);
101
        } catch (ErrorCachedVersionException $e) {
102
            $logger->debug($e);
103
104
            return 3;
105
        } catch (FetcherException $e) {
106
            $logger->debug($e);
107
108
            return 9;
109
        } catch (Exception $e) {
110
            $logger->debug($e);
111
112
            return 10;
113
        }
114
115
        $logger->info('finished fetching remote file');
116
117
        return 0;
118
    }
119
}
120