| Total Complexity | 6 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | public function __construct(bool $isBatch = false) |
||
| 21 | { |
||
| 22 | $this->isBatch = $isBatch; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param JsonRpcRequest|\Exception $item |
||
| 27 | * |
||
| 28 | * @return JsonRpcRawRequest |
||
| 29 | */ |
||
| 30 | public function addItem(object $item) : JsonRpcRawRequest |
||
| 31 | { |
||
| 32 | if (!$item instanceof JsonRpcResponse && !$item instanceof \Exception) { |
||
| 33 | throw new \InvalidArgumentException( |
||
| 34 | sprintf( |
||
| 35 | 'item must be either an instance of %s or an instance of %s', |
||
| 36 | JsonRpcRequest::class, |
||
| 37 | \Exception::class |
||
| 38 | ) |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->itemList[] = $item; |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return boolean |
||
| 49 | */ |
||
| 50 | public function isBatch() : bool |
||
| 51 | { |
||
| 52 | return $this->isBatch; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return (JsonRpcRequest|\Exception)[] |
||
| 57 | */ |
||
| 58 | public function getItemtList() : array |
||
| 61 | } |
||
| 62 | } |
||
| 63 |