/ src / Control / Control.php
Control.php
 1  <?php
 2  
 3  namespace BitcoindRPC\Control;
 4  
 5  use BitcoindRPC\RpcClient;
 6  use BitcoindRPC\RpcResponse;
 7  
 8  class Control
 9  {
10      private RpcClient $client;
11  
12      public function __construct(RpcClient $client)
13      {
14          $this->client = $client;
15      }
16  
17      public function getMemoryInfo(): ControlResult
18      {
19          $response = $this->client->call('getmemoryinfo');
20          return new ControlResult($response);
21      }
22  
23      public function getRpcInfo(): ControlResult
24      {
25          $response = $this->client->call('getrpcinfo');
26          return new ControlResult($response);
27      }
28  
29      public function help(?string $command = null): ControlResult
30      {
31          $params = [];
32          if ($command !== null) {
33              $params[] = $command;
34          }
35          $response = $this->client->call('help', $params);
36          return new ControlResult($response);
37      }
38  
39      public function stop(): ControlResult
40      {
41          $response = $this->client->call('stop');
42          return new ControlResult($response);
43      }
44  
45      public function logging(array $include = [], array $exclude = []): ControlResult
46      {
47          $params = [];
48          if (!empty($include)) {
49              $params[] = $include;
50          }
51          if (!empty($exclude)) {
52              if (empty($include)) {
53                  $params[] = [];
54              }
55              $params[] = $exclude;
56          }
57          $response = $this->client->call('logging', $params);
58          return new ControlResult($response);
59      }
60  
61      public function uptime(): ControlResult
62      {
63          $response = $this->client->call('uptime');
64          return new ControlResult($response);
65      }
66  
67      public function getNetworkInfo(): ControlResult
68      {
69          $response = $this->client->call('getnetworkinfo');
70          return new ControlResult($response);
71      }
72  
73      public function getBlockchainInfo(): ControlResult
74      {
75          $response = $this->client->call('getblockchaininfo');
76          return new ControlResult($response);
77      }
78  }