Completed
Push — master ( f735c4...3825d6 )
by Hiraku
7s
created

GitLabRequest::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 3
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
class GitLabRequest extends HttpGetRequest
16
{
17
    const TOKEN_LABEL = 'gitlab-token';
18
19 4
    public function __construct($origin, $url, IO\IOInterface $io)
20
    {
21 4
        parent::__construct($origin, $url, $io);
22 4
        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 4
    }
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