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
Pull Request — master (#2)
by Cees-Jan
07:01
created

StreamingResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Rx\Observable;
7
use Rx\ObserverInterface;
8
use Rx\SchedulerInterface;
9
10
final class StreamingResponse
11
{
12
    /**
13
     * @var ResponseInterface
14
     */
15
    private $response;
16
17
    /**
18
     * @param ResponseInterface $response
19
     */
20
    public function __construct(ResponseInterface $response)
21
    {
22
        $this->response = $response;
23
    }
24
25
    /**
26
     * @return ResponseInterface
27
     */
28
    public function getResponse(): ResponseInterface
29
    {
30
        return $this->response;
31
    }
32
33
    /**
34
     * @return Observable
35
     */
36
    public function subscribe(): Observable
37
    {
38
        return Observable::create(function (
39
            ObserverInterface $observer,
40
            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...
41
        ) {
42
            $body = $this->response->getBody();
43
            $body->on('data', function (string $data) use ($observer) {
44
                $observer->onNext($data);
45
            });
46
            $body->on('end', function () use ($observer) {
47
                $observer->onCompleted();
48
            });
49
            $body->on('error', function ($error) use ($observer) {
50
                $observer->onError($error);
51
            });
52
        });
53
    }
54
}
55