Code Duplication    Length = 23-23 lines in 2 locations

src/CurlRemoteFilesystem.php 2 locations

@@ 259-281 (lines=23) @@
256
        $io = $this->io;
257
        $httpCode = $res->info['http_code'];
258
259
        if ('github' === $req->special) {
260
            $message = "\nCould not fetch {$req->getURL()}, please create a GitHub OAuth token ";
261
            if (404 === $httpCode) {
262
                $message .= 'to access private repos';
263
            } else {
264
                $message .= 'to go over the API rate limit';
265
            }
266
            $github = new Util\GitHub($io, $this->config, null);
267
            if ($github->authorizeOAuth($req->origin)) {
268
                $this->_retry = true;
269
                return;
270
            }
271
            if ($io->isInteractive() &&
272
                $github->authorizeOAuthInteractively($req->origin, $message)) {
273
                $this->_retry = true;
274
                return;
275
            }
276
277
            throw new Downloader\TransportException(
278
                "Could not authenticate against $req->origin",
279
                401
280
            );
281
        }
282
        
283
        if ('gitlab' === $req->special) {
284
            $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials ";
@@ 283-305 (lines=23) @@
280
            );
281
        }
282
        
283
        if ('gitlab' === $req->special) {
284
            $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials ";
285
            if (401 === $httpCode) {
286
                $message .= 'to access private repos';
287
            } else {
288
                $message .= 'to go over the API rate limit';
289
            }
290
            $gitlab = new Util\GitLab($io, $this->config, null);
291
            if ($gitlab->authorizeOAuth($req->origin)) {
292
                $this->_retry = true;
293
                return;
294
            }
295
            if ($io->isInteractive() &&
296
                $gitlab->authorizeOAuthInteractively($req->origin, $message)) {
297
                $this->_retry = true;
298
                return;
299
            }
300
301
            throw new Downloader\TransportException(
302
                "Could not authenticate against $req->origin",
303
                401
304
            );
305
        }
306
307
        // 404s are only handled for github
308
        if (404 === $httpCode) {