PromiseResponse::then()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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