Code Duplication    Length = 23-23 lines in 2 locations

src/CurlRemoteFilesystem.php 2 locations

@@ 280-302 (lines=23) @@
277
        $io = $this->io;
278
        $httpCode = $res->info['http_code'];
279
280
        if ('github' === $req->special) {
281
            $message = "\nCould not fetch {$req->getURL()}, please create a GitHub OAuth token ";
282
            if (404 === $httpCode) {
283
                $message .= 'to access private repos';
284
            } else {
285
                $message .= 'to go over the API rate limit';
286
            }
287
            $github = new Util\GitHub($io, $this->config, null);
288
            if ($github->authorizeOAuth($req->origin)) {
289
                $this->retry = true;
290
                return;
291
            }
292
            if ($io->isInteractive() &&
293
                $github->authorizeOAuthInteractively($req->origin, $message)) {
294
                $this->retry = true;
295
                return;
296
            }
297
298
            throw new Downloader\TransportException(
299
                "Could not authenticate against $req->origin",
300
                401
301
            );
302
        }
303
        
304
        if ('gitlab' === $req->special) {
305
            $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials ";
@@ 304-326 (lines=23) @@
301
            );
302
        }
303
        
304
        if ('gitlab' === $req->special) {
305
            $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials ";
306
            if (401 === $httpCode) {
307
                $message .= 'to access private repos';
308
            } else {
309
                $message .= 'to go over the API rate limit';
310
            }
311
            $gitlab = new Util\GitLab($io, $this->config, null);
312
            if ($gitlab->authorizeOAuth($req->origin)) {
313
                $this->retry = true;
314
                return;
315
            }
316
            if ($io->isInteractive() &&
317
                $gitlab->authorizeOAuthInteractively($req->origin, $message)) {
318
                $this->retry = true;
319
                return;
320
            }
321
322
            throw new Downloader\TransportException(
323
                "Could not authenticate against $req->origin",
324
                401
325
            );
326
        }
327
328
        // 404s are only handled for github
329
        if (404 === $httpCode) {