| Total Complexity | 8 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 95% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class NodeService |
||
| 12 | { |
||
| 13 | 10 | protected function checkBitcoindExists(string $bitcoind) |
|
| 14 | { |
||
| 15 | 10 | if (!file_exists($bitcoind)) { |
|
| 16 | 1 | throw new Exception\SetupException("Path to bitcoind executable is invalid: {$bitcoind}"); |
|
| 17 | } |
||
| 18 | |||
| 19 | 9 | if (!is_executable($bitcoind)) { |
|
| 20 | 1 | throw new Exception\SetupException("Bitcoind must be executable"); |
|
| 21 | } |
||
| 22 | 8 | } |
|
| 23 | |||
| 24 | 8 | protected function setupDataDir(NodeOptions $options, Config\Config $config, Config\Writer $writer) |
|
| 35 | 7 | } |
|
| 36 | |||
| 37 | 10 | public function createNewNode(NodeOptions $options, Config\Config $config, Config\Writer $writer): Server |
|
| 38 | { |
||
| 39 | 10 | $this->checkBitcoindExists($options->getBitcoindPath()); |
|
| 40 | 8 | $this->setupDataDir($options, $config, $writer); |
|
| 41 | |||
| 42 | 7 | return new Server($options); |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | public function loadNode(NodeOptions $options): Server |
|
| 49 | } |
||
| 50 | } |
||
| 51 |