1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by PhpStorm. |
5
|
|
|
* Project: json-rpc-server |
6
|
|
|
* User: sv |
7
|
|
|
* Date: 06.01.2021 |
8
|
|
|
* Time: 19:17 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace Onnov\JsonRpcServer\Model; |
14
|
|
|
|
15
|
|
|
use Onnov\JsonRpcServer\RpcFactoryInterface; |
16
|
|
|
use Onnov\JsonRpcServer\Definition\RpcAuthDefinition; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class RpcRun |
20
|
|
|
* |
21
|
|
|
* @package Onnov\JsonRpcServer\Model |
22
|
|
|
*/ |
23
|
|
|
class RpcRun |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var RpcFactoryInterface |
27
|
|
|
*/ |
28
|
|
|
private $rpcFactory; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $json; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var RpcAuthDefinition |
37
|
|
|
*/ |
38
|
|
|
private $auth; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var bool |
42
|
|
|
*/ |
43
|
|
|
private $responseCheck; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* RunModel constructor. |
47
|
|
|
* |
48
|
|
|
* @param mixed[] $data |
49
|
|
|
*/ |
50
|
9 |
|
public function __construct(array $data = []) |
51
|
|
|
{ |
52
|
9 |
|
if (isset($data['rpcFactory'])) { |
53
|
9 |
|
$this->rpcFactory = $data['rpcFactory']; |
54
|
|
|
} |
55
|
9 |
|
if (isset($data['json'])) { |
56
|
9 |
|
$this->json = $data['json']; |
57
|
|
|
} |
58
|
|
|
|
59
|
9 |
|
$this->auth = $data['auth'] ?? new RpcAuthDefinition(); |
60
|
9 |
|
$this->responseCheck = $data['responseCheck'] ?? false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return RpcFactoryInterface |
65
|
|
|
*/ |
66
|
6 |
|
public function getRpcFactory(): RpcFactoryInterface |
67
|
|
|
{ |
68
|
6 |
|
return $this->rpcFactory; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param RpcFactoryInterface $rpcFactory |
73
|
|
|
* @return RpcRun |
74
|
|
|
*/ |
75
|
|
|
public function setRpcFactory(RpcFactoryInterface $rpcFactory): self |
76
|
|
|
{ |
77
|
|
|
$this->rpcFactory = $rpcFactory; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
9 |
|
public function getJson(): string |
86
|
|
|
{ |
87
|
9 |
|
return $this->json; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string $json |
92
|
|
|
* @return RpcRun |
93
|
|
|
*/ |
94
|
|
|
public function setJson(string $json): self |
95
|
|
|
{ |
96
|
|
|
$this->json = $json; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return RpcAuthDefinition |
103
|
|
|
*/ |
104
|
9 |
|
public function getAuth(): RpcAuthDefinition |
105
|
|
|
{ |
106
|
9 |
|
return $this->auth; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param RpcAuthDefinition $auth |
111
|
|
|
* @return RpcRun |
112
|
|
|
*/ |
113
|
|
|
public function setAuth(RpcAuthDefinition $auth): self |
114
|
|
|
{ |
115
|
|
|
$this->auth = $auth; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return bool |
122
|
|
|
*/ |
123
|
5 |
|
public function isResponseCheck(): bool |
124
|
|
|
{ |
125
|
5 |
|
return $this->responseCheck; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param bool $responseCheck |
130
|
|
|
* @return RpcRun |
131
|
|
|
*/ |
132
|
|
|
public function setResponseCheck(bool $responseCheck): self |
133
|
|
|
{ |
134
|
|
|
$this->responseCheck = $responseCheck; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|