Failed Conditions
Pull Request — release/3.0.0 (#37)
by Yo
01:46
created

JsonRpcRawRequest::addRequestItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Yoanm\JsonRpcServer\Infra\RawObject;
3
4
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcRequest;
5
6
/**
7
 * Class JsonRpcRawRequest
8
 */
9
class JsonRpcRawRequest
10
{
11
    /** @var bool */
12
    private $isBatch;
13
    /** @var mixed[] */
14
    private $itemList = [];
15
16
    /**
17
     * @param bool|false $isBatch
18
     */
19
    public function __construct(bool $isBatch = false)
20
    {
21
        $this->isBatch = $isBatch;
22
    }
23
24
    /**
25
     * @param JsonRpcRequest $item
26
     *
27
     * @return JsonRpcRawRequest
28
     */
29
    public function addRequestItem(JsonRpcRequest $item) : JsonRpcRawRequest
30
    {
31
        $this->itemList[] = $item;
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param \Exception $item
38
     *
39
     * @return JsonRpcRawRequest
40
     */
41
    public function addExceptionItem(\Exception $item) : JsonRpcRawRequest
42
    {
43
        $this->itemList[] = $item;
44
45
        return $this;
46
    }
47
48
    /**
49
     * @return boolean
50
     */
51
    public function isBatch() : bool
52
    {
53
        return $this->isBatch;
54
    }
55
56
    /**
57
     * @return (JsonRpcRequest|\Exception)[]
58
     */
59
    public function getItemtList() : array
60
    {
61
        return $this->itemList;
62
    }
63
}
64