PromiseResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 6
c 1
b 0
f 1
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A then() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React;
6
7
use Psr\Http\Message\ResponseInterface;
8
use React\Promise\PromiseInterface;
9
use RingCentral\Psr7\Response;
10
use Throwable;
11
12
class PromiseResponse extends Response implements PromiseInterface
13
{
14
    private PromiseInterface $promise;
15
    protected $stream;
16
17
    /**
18
     * @param PromiseInterface $promise
19
     * @param mixed $body
20
     * @param int $status
21
     * @param array $headers
22
     */
23 8
    public function __construct(
24
        PromiseInterface $promise,
25
        $body = null,
26
        int $status = 200,
27
        array $headers = []
28
    ) {
29 8
        parent::__construct($status, $headers, $body);
30 8
        $this->promise = $promise;
31 8
    }
32
33 8
    final public function then(
34
        callable $onFulfilled = null,
35
        callable $onRejected = null,
36
        callable $onProgress = null
37
    ): PromiseInterface {
38 8
        return $this->promise->then($onFulfilled, $onRejected, $onProgress);
39
    }
40
}
41