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.

Job::log()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
eloc 15
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\Travis\Resource\Async;
5
6
use ApiClients\Client\Pusher\CommandBus\Command\SharedAppClientCommand;
7
use ApiClients\Foundation\Hydrator\CommandBus\Command\HydrateCommand;
8
use ApiClients\Foundation\Transport\CommandBus\Command\SimpleRequestCommand;
9
use React\Promise\PromiseInterface;
10
use Rx\Observable;
11
use Rx\ObservableInterface;
12
use Rx\Observer\CallbackObserver;
13
use Rx\ObserverInterface;
14
use Rx\React\Promise;
15
use Rx\SchedulerInterface;
16
use WyriHaximus\Travis\ApiSettings;
17
use WyriHaximus\Travis\Resource\Job as BaseJob;
18
use function React\Promise\resolve;
19
20
class Job extends BaseJob
21
{
22
    public function log(): ObservableInterface
23
    {
24
        return Observable::create(function (
25
            ObserverInterface $observer,
26
            SchedulerInterface $scheduler
0 ignored issues
show
Unused Code introduced by
The parameter $scheduler is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
        ) {
28
            $this->handleCommand(
29
                new SharedAppClientCommand(ApiSettings::PUSHER_KEY)
30
            )->then(function ($pusher) use ($observer) {
31
                $pusher->channel('job-' . $this->id)->filter(function ($message) {
32
                    return $message->event == 'job:log';
33
                })->map(function ($message) {
34
                    return json_decode($message->data, true);
35
                })->flatMap(function (array $json) {
36
                    return Promise::toObservable($this->handleCommand(new HydrateCommand('LogLine', $json)));
37
                })->subscribe(new CallbackObserver(function ($repository) use ($observer) {
38
                    $observer->onNext($repository);
39
                }));
40
            });
41
        });
42
    }
43
    /**
44
     * @return ObservableInterface
45
     */
46 View Code Duplication
    public function annotations(): ObservableInterface
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...
47
    {
48
        return Promise::toObservable(
49
            $this->handleCommand(new SimpleRequestCommand('jobs/' . $this->id() . '/annotations'))
50
        )->flatMap(function ($response) {
51
            return Observable::fromArray($response['annotations']);
52
        })->flatMap(function ($annotation) {
53
            return Promise::toObservable($this->handleCommand(new HydrateCommand('Annotation', $annotation)));
54
        });
55
    }
56
57
    /**
58
     * @return PromiseInterface
59
     */
60
    public function refresh(): PromiseInterface
61
    {
62
        return $this->handleCommand(new SimpleRequestCommand('jobs/' . $this->id))->then(function ($json) {
63
            return resolve($this->handleCommand(new HydrateCommand('Job', $json['job'])));
64
        });
65
    }
66
}
67