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

GitHubRequest::__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
 * GitHub edition
14
 */
15
class GitHubRequest extends HttpGetRequest
16
{
17
    const TOKEN_LABEL = 'github-token';
18
19 6
    public function __construct($origin, $url, IO\IOInterface $io)
20
    {
21 6
        parent::__construct($origin, $url, $io);
22 6
        if ($this->password === 'x-oauth-basic') {
23 1
            $this->query['access_token'] = $this->username;
24
            // forbid basic-auth
25 1
            $this->username = $this->password = null;
26 1
        }
27 6
    }
28
29 3
    public function getURL()
30
    {
31 3
        return preg_replace(
32 3
            '%^https://api\.github\.com/repos(/[^/]+/[^/]+/)zipball(.*)%',
33 3
            'https://codeload.github.com$1legacy.zip$2',
34 3
            parent::getURL()
35 3
        );
36
    }
37
38 1
    public function promptAuth(HttpGetResponse $res, IO\IOInterface $io)
39
    {
40 1
        $util = new \Composer\Util\GitHub($io, $this->config, null);
41 1
        $this->promptAuthWithUtil(404, $util, $res, $io);
0 ignored issues
show
Documentation introduced by
$util is of type object<Composer\Util\GitHub>, but the function expects a object<Composer\Composer...r\Composer\Util\GitLab>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42 1
    }
43
}
44