Passed
Push — master ( 465b21...de1506 )
by Koldo
05:36
created

PromiseResponse::promise()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React;
6
7
use React\Http\Response;
8
use React\Promise\PromiseInterface;
9
10
class PromiseResponse extends Response implements PromiseInterface
11
{
12
    private $promise;
13
14
    public function __construct(
15
        PromiseInterface $promise,
16
        $body = 'php://tmp',
17
        int $status = 200,
18
        array $headers = []
19
    ) {
20
        parent::__construct($status, $headers, $body);
21
        $this->promise = $promise;
22
    }
23
24
    public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
25
    {
26
        return $this->promise->then($onFulfilled, $onRejected, $onProgress);
27
    }
28
29
    public function promise(): PromiseInterface
30
    {
31
        return $this->promise;
32
    }
33
}
34