MiningClient   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 53
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A subscribeMining() 0 4 1
A authorize() 0 4 1
A submit() 0 4 1
1
<?php
2
3
namespace BitWasp\Stratum\Api;
4
5
use BitWasp\Stratum\Connection;
6
7
class MiningClient
8
{
9
    const MINING_SUBSCRIBE = 'mining.subscribe';
10
    const SET_DIFFICULTY = 'mining.set_difficulty';
11
    const NOTIFY = 'mining.notify';
12
    const AUTHORIZE = 'mining.authorize';
13
    const SUBMIT = 'mining.submit';
14
15
    /**
16
     * @var Connection
17
     */
18
    private $conn;
19
20
    /**
21
     * MiningServer constructor.
22
     * @param Connection $connection
23
     */
24 3
    public function __construct(Connection $connection)
25
    {
26 3
        $this->conn = $connection;
27 3
    }
28
29
    /**
30
     * @return \React\Promise\Promise|\React\Promise\PromiseInterface
31
     */
32 1
    public function subscribeMining()
33
    {
34 1
        return $this->conn->request(self::MINING_SUBSCRIBE);
35
    }
36
37
    /**
38
     * @param string $user
39
     * @param string $password
40
     * @return \React\Promise\Promise|\React\Promise\PromiseInterface
41
     */
42 1
    public function authorize($user, $password)
43
    {
44 1
        return $this->conn->request(self::AUTHORIZE, [$user, $password]);
45
    }
46
47
    /**
48
     * @param string $worker_name
49
     * @param string $job_id
50
     * @param int $extranonce2
51
     * @param int $ntime
52
     * @param int $nonce
53
     * @return \React\Promise\Promise|\React\Promise\PromiseInterface
54
     */
55 1
    public function submit($worker_name, $job_id, $extranonce2, $ntime, $nonce)
56
    {
57 1
        return $this->conn->request(self::SUBMIT, [$worker_name, $job_id, $extranonce2, $ntime, $nonce]);
58
    }
59
}
60