PromiseResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A promise() 0 3 1
A then() 0 6 1
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 PromiseInterface $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(
25
        callable $onFulfilled = null,
26
        callable $onRejected = null,
27
        callable $onProgress = null
28
    ): PromiseInterface {
29
        return $this->promise->then($onFulfilled, $onRejected, $onProgress);
30
    }
31
32
    public function promise(): PromiseInterface
33
    {
34
        return $this->promise;
35
    }
36
}
37