Test Failed
Push — feature/init ( ecfce8...b38e47 )
by Yo
05:12
created

JsonRpcRawResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Yoanm\JsonRpcServer\Infra\RawObject;
3
4
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcResponse;
5
6
/**
7
 * Class JsonRpcRawResponse
8
 */
9
class JsonRpcRawResponse
10
{
11
    /** @var bool */
12
    private $isBatch;
13
    /** @var null|JsonRpcRawRequest */
14
    private $request;
15
    /** @var JsonRpcResponse[] */
16
    private $responseList = [];
17
18
    /**
19
     * @param bool $isBatch
20
     */
21
    public function __construct(bool $isBatch = false)
22
    {
23
        $this->isBatch = $isBatch;
24
    }
25
26
    /**
27
     * @param JsonRpcRawRequest $request
28
     *
29
     * @return JsonRpcRawRequest
30
     */
31
    public function setRequest(JsonRpcRawRequest $request) : JsonRpcRawRequest
32
    {
33
        $this->request = $request;
34
        $this->isBatch = $request->isBatch();
35
36
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Yoanm\JsonRpcServer\Infr...ject\JsonRpcRawResponse which is incompatible with the type-hinted return Yoanm\JsonRpcServer\Infr...bject\JsonRpcRawRequest.
Loading history...
37
    }
38
39
    /**
40
     * @param JsonRpcResponse $response
41
     *
42
     * @return JsonRpcRawResponse
43
     */
44
    public function addResponse(JsonRpcResponse $response) : JsonRpcRawResponse
45
    {
46
        $this->responseList[] = $response;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return boolean
53
     */
54
    public function isBatch() : bool
55
    {
56
        return $this->isBatch;
57
    }
58
59
    /**
60
     * @return JsonRpcResponse[]
61
     */
62
    public function getResponseList() : array
63
    {
64
        return $this->responseList;
65
    }
66
67
    /**
68
     * @return null|JsonRpcRawRequest
69
     */
70
    public function getRequest()
71
    {
72
        return $this->request;
73
    }
74
}
75