Completed
Push — master ( 5c78d7...6647db )
by thomas
8s
created

MiningNotification::toRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BitWasp\Stratum\Notification;
4
5
use BitWasp\Stratum\Api\MiningClient;
6
use BitWasp\Stratum\Request\Request;
7
8
class MiningNotification implements NotificationInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $job_id;
14
15
    /**
16
     * @var string
17
     */
18
    private $prevhash;
19
20
    /**
21
     * @var string
22
     */
23
    private $coinb1;
24
25
    /**
26
     * @var string
27
     */
28
    private $coinb2;
29
30
    /**
31
     * @var array
32
     */
33
    private $merkle_branch;
34
35
    /**
36
     * @var int
37
     */
38
    private $version;
39
40
    /**
41
     * @var int
42
     */
43
    private $nbits;
44
45
    /**
46
     * @var int
47
     */
48
    private $ntime;
49
50
    /**
51
     * @var bool
52
     */
53
    private $clean_jobs;
54
55
    /**
56
     * MiningNotification constructor.
57
     * @param string $job_id
58
     * @param string $prevhash
59
     * @param string $coinb1
60
     * @param string $coinb2
61
     * @param array $merkle_branch
62
     * @param int $version
63
     * @param int $bits
64
     * @param int $time
65
     * @param bool $cleanjobs
66
     */
67 3
    public function __construct($job_id, $prevhash, $coinb1, $coinb2, $merkle_branch, $version, $bits, $time, $cleanjobs)
68
    {
69 3
        $this->job_id = $job_id;
70 3
        $this->prevhash = $prevhash;
71 3
        $this->coinb1 = $coinb1;
72 3
        $this->coinb2 = $coinb2;
73 3
        $this->merkle_branch = $merkle_branch;
74 3
        $this->version = $version;
75 3
        $this->nbits = $bits;
76 3
        $this->ntime = $time;
77 3
        $this->clean_jobs = $cleanjobs;
78 3
    }
79
80
    /**
81
     * @return string
82
     */
83 1
    public function getJobId()
84
    {
85 1
        return $this->job_id;
86
    }
87
88
    /**
89
     * @return string
90
     */
91 1
    public function getPrevhash()
92
    {
93 1
        return $this->prevhash;
94
    }
95
96
    /**
97
     * @return string
98
     */
99 1
    public function getCoinb1()
100
    {
101 1
        return $this->coinb1;
102
    }
103
104
    /**
105
     * @return string
106
     */
107 1
    public function getCoinb2()
108
    {
109 1
        return $this->coinb2;
110
    }
111
112
    /**
113
     * @return array
114
     */
115 1
    public function getMerkleBranch()
116
    {
117 1
        return $this->merkle_branch;
118
    }
119
120
    /**
121
     * @return int
122
     */
123 1
    public function getVersion()
124
    {
125 1
        return $this->version;
126
    }
127
128
    /**
129
     * @return int
130
     */
131 1
    public function getBits()
132
    {
133 1
        return $this->nbits;
134
    }
135
136
    /**
137
     * @return int
138
     */
139 1
    public function getTime()
140
    {
141 1
        return $this->ntime;
142
    }
143
144
    /**
145
     * @return boolean
146
     */
147 1
    public function isCleanJobs()
148
    {
149 1
        return $this->clean_jobs;
150
    }
151
152
    /**
153
     * @return Request
154
     */
155 2
    public function toRequest()
156
    {
157 2
        return new Request(null, MiningClient::MINING_SUBSCRIBE, [$this->job_id, $this->prevhash, $this->coinb1, $this->coinb2, $this->merkle_branch, $this->version, $this->nbits, $this->ntime, $this->clean_jobs]);
158
    }
159
}
160