Completed
Pull Request — master (#68)
by Hiraku
03:25
created

GitLabRequest::promptAuth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 5
Bugs 0 Features 1
Metric Value
c 5
b 0
f 1
dl 5
loc 5
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
/*
3
 * hirak/prestissimo
4
 * @author Hiraku NAKANO
5
 * @license MIT https://github.com/hirak/prestissimo
6
 */
7
namespace Hirak\Prestissimo\Aspects;
8
9
use Composer\IO;
10
11
/**
12
 * Simple Container for http-get request
13
 * GitLab edition
14
 */
15 View Code Duplication
class GitLabRequest extends HttpGetRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
16
{
17
    const TOKEN_LABEL = 'gitlab-token';
18
19 2
    public function __construct($origin, $url, IO\IOInterface $io)
20
    {
21 2
        parent::__construct($origin, $url, $io);
22 2
        if ($this->password === 'oauth2') {
23 1
            $this->headers[] = 'Authorization: Bearer ' . $this->username;
24
            // forbid basic-auth
25 1
            $this->username = $this->password = null;
26 1
        }
27 2
    }
28
29
    /**
30
     * @codeCoverageIgnore
31
     */
32
    public function promptAuth(HttpGetResponse $res, IO\IOInterface $io)
33
    {
34
        $util = new \Composer\Util\GitLab($io, $this->config, null);
35
        $this->promptAuthWithUtil(401, $util, $res, $io);
36
    }
37
}
38