Passed
Pull Request — feature/app (#9)
by Yo
01:42
created

JsonRpcRawRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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