55use Illuminate \Contracts \Support \Arrayable ;
66use Illuminate \Contracts \Support \Jsonable ;
77use Tochka \JsonRpc \Standard \Contracts \JsonRpcInterface ;
8- use Tochka \JsonRpc \Standard \Exceptions \InvalidRequestException ;
98use Tochka \JsonRpc \Standard \Exceptions \InvalidResponseException ;
109use Tochka \JsonRpc \Standard \Helpers \PrepareValue ;
1110
@@ -40,24 +39,24 @@ public function __construct(string|int|null $id = null, mixed $result = null, Js
4039 public static function from (object |array $ value ): self
4140 {
4241 if (is_array ($ value )) {
43- $ value = (object )$ value ;
42+ $ value = (object ) $ value ;
4443 }
4544
4645 if (empty ($ value ->jsonrpc ) || $ value ->jsonrpc !== self ::VERSION ) {
4746 throw InvalidResponseException::from ('jsonrpc ' , 'Field must be [2.0] ' );
4847 }
4948
5049 if (empty ($ value ->id )) {
51- throw InvalidRequestException ::from ('id ' , 'Field must be present ' );
50+ throw InvalidResponseException ::from ('id ' , 'Field must be present ' );
5251 }
5352
5453 if (!is_string ($ value ->id ) && !is_int ($ value ->id )) {
55- throw InvalidRequestException ::from ('id ' , 'Field must be of type [string|int] ' );
54+ throw InvalidResponseException ::from ('id ' , 'Field must be of type [string|int] ' );
5655 }
5756
5857 if (isset ($ value ->error )) {
5958 if (!is_array ($ value ->error ) && !is_object ($ value ->error )) {
60- throw InvalidRequestException ::from ('error ' , 'Field must be of type [array|object] ' );
59+ throw InvalidResponseException ::from ('error ' , 'Field must be of type [array|object] ' );
6160 }
6261
6362 $ error = JsonRpcError::from ($ value ->error );
@@ -68,7 +67,7 @@ public static function from(object|array $value): self
6867 return new self (
6968 $ value ->id ,
7069 $ value ->result ?? null ,
71- $ error
70+ $ error,
7271 );
7372 }
7473
@@ -79,7 +78,7 @@ public function toArray(): array
7978 {
8079 $ result = [
8180 'jsonrpc ' => $ this ->jsonrpc ,
82- 'id ' => $ this ->id
81+ 'id ' => $ this ->id ,
8382 ];
8483
8584 if ($ this ->result !== null ) {
@@ -101,7 +100,7 @@ public function jsonSerialize(): array
101100 {
102101 $ result = [
103102 'jsonrpc ' => $ this ->jsonrpc ,
104- 'id ' => $ this ->id
103+ 'id ' => $ this ->id ,
105104 ];
106105
107106 if ($ this ->result !== null ) {
0 commit comments