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

JsonRpcRawRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 53
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addRequestItem() 0 5 1
A getItemtList() 0 3 1
A __construct() 0 3 1
A isBatch() 0 3 1
A addExceptionItem() 0 5 1
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