Conditions | 5 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 23 |
Ratio | 100 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function promptAuth(HttpGetResponse $res, IO\IOInterface $io) |
||
27 | { |
||
28 | $httpCode = $res->info['http_code']; |
||
29 | $message = "\nCould not fetch {$this->getURL()}, enter your $this->origin credentials "; |
||
30 | if (401 === $httpCode) { |
||
31 | $message .= 'to access private repos'; |
||
32 | } else { |
||
33 | $message .= 'to go over the API rate limit'; |
||
34 | } |
||
35 | $gitlab = new Util\GitLab($io, $this->config, null); |
||
36 | if ($gitlab->authorizeOAuth($this->origin)) { |
||
37 | return true; |
||
38 | } |
||
39 | if ($io->isInteractive() && |
||
40 | $gitlab->authorizeOAuthInteractively($this->origin, $message)) { |
||
41 | return true; |
||
42 | } |
||
43 | |||
44 | throw new Downloader\TransportException( |
||
45 | "Could not authenticate against $this->origin", |
||
46 | 401 |
||
47 | ); |
||
48 | } |
||
49 | } |
||
50 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.