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
19:15 queued 09:29
created

StreamingResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResponse() 0 4 1
A subscribe() 0 15 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Rx\Disposable\EmptyDisposable;
7
use Rx\DisposableInterface;
8
use Rx\Observable;
9
use Rx\ObserverInterface;
10
use Rx\SchedulerInterface;
11
12
final class StreamingResponse extends Observable
13
{
14
    /**
15
     * @var ResponseInterface
16
     */
17
    private $response;
18
19
    /**
20
     * @param ResponseInterface $response
21
     */
22
    public function __construct(ResponseInterface $response)
23
    {
24
        $this->response = $response;
25
    }
26
27
    /**
28
     * @return ResponseInterface
29
     */
30
    public function getResponse(): ResponseInterface
31
    {
32
        return $this->response;
33
    }
34
35
    /**
36
     * @param ObserverInterface $observer
37
     * @param SchedulerInterface $scheduler
38
     * @return DisposableInterface
39
     */
40
    public function subscribe(ObserverInterface $observer, SchedulerInterface $scheduler = null): DisposableInterface
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
        return new EmptyDisposable();
54
    }
55
}
56