GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 352f99...e3c5ff )
by Cees-Jan
09:24
created

BuildMatrix   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 10

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 10
dl 49
loc 49
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A getRequest() 7 7 1
A fromResponse() 6 6 1
A createJobs() 8 8 2
A matrix() 4 4 1

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
namespace WyriHaximus\Travis;
4
5
use Iterator;
6
use Psr\Http\Message\RequestInterface;
7
use Psr\Http\Message\ResponseInterface;
8
use React\Promise\CancellablePromiseInterface;
9
use React\Promise\ExtendedPromiseInterface;
10
11 View Code Duplication
class BuildMatrix implements Iterator, ExtendedPromiseInterface, CancellablePromiseInterface, EndpointInterface
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...
12
{
13
    use IteratorTrait;
14
    use LazyPromiseTrait;
15
    use ParentHasClientAwareTrait;
16
17
    /**
18
     * @var Build
19
     */
20
    protected $build;
21
22
    public function __construct(Build $build)
23
    {
24
        $this->setFactory(function () {
25
            return $this->getClient()->requestAsync($this);
26
        });
27
        $this->setParent($build);
28
        $this->build = $build;
29
    }
30
31
    public function getRequest(): RequestInterface
32
    {
33
        return $this->parent->getClient()->createRequest(
34
            'GET',
35
            'builds/' . $this->build->getId()
36
        );
37
    }
38
39
    public function fromResponse(ResponseInterface $response): EndpointInterface
40
    {
41
        $json = json_decode($response->getBody()->getContents());
42
        $jobs = $this->createJobs($json);
43
        return new JobCollection($this->build, $jobs);
44
    }
45
46
    protected function createJobs($json)
47
    {
48
        $builds = [];
49
        foreach ($json->jobs as $build) {
50
            $builds[] = new Job($this->build, $build);
51
        }
52
        return $builds;
53
    }
54
55
    public function matrix()
56
    {
57
58
    }
59
}
60