Completed
Pull Request — master (#80)
by Hiraku
02:20
created

GitLabRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 64.29 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 9
loc 14
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/*
3
 * hirak/prestissimo
4
 * @author Hiraku NAKANO
5
 * @license MIT https://github.com/hirak/prestissimo
6
 */
7
namespace Hirak\Prestissimo;
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 View Code Duplication
    public function __construct($origin, $url, IO\IOInterface $io)
0 ignored issues
show
Duplication introduced by
This method 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...
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