PromiseResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A then() 0 3 1
A __construct() 0 8 1
A promise() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React\PSR15\Response;
6
7
use RingCentral\Psr7\Response;
8
use React\Promise\PromiseInterface;
9
10
class PromiseResponse extends Response implements PromiseInterface
11
{
12
    private PromiseInterface $promise;
13
14
    /**
15
     * PromiseResponse constructor.
16
     * @param PromiseInterface $promise
17
     * @param null $body
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $body is correct as it would always require null to be passed?
Loading history...
18
     * @param int $status
19
     * @param array<array<string>> $headers
20
     */
21
    public function __construct(
22
        PromiseInterface $promise,
23
        $body = null,
24
        int $status = 200,
25
        array $headers = []
26
    ) {
27
        parent::__construct($status, $headers, $body);
28
        $this->promise = $promise;
29
    }
30
31
    public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
32
    {
33
        return $this->promise->then($onFulfilled, $onRejected, $onProgress);
34
    }
35
36
    public function promise(): PromiseInterface
37
    {
38
        return $this->promise;
39
    }
40
}
41