Completed
Pull Request — master (#3)
by thomas
25:38
created

MiningNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 10
nc 1
nop 9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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
    public function __construct($job_id, $prevhash, $coinb1, $coinb2, $merkle_branch, $version, $bits, $time, $cleanjobs)
68
    {
69
        $this->job_id = $job_id;
70
        $this->prevhash = $prevhash;
71
        $this->coinb1 = $coinb1;
72
        $this->coinb2 = $coinb2;
73
        $this->merkle_branch = $merkle_branch;
74
        $this->version = $version;
75
        $this->nbits = $bits;
76
        $this->ntime = $time;
77
        $this->clean_jobs = $cleanjobs;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getJobId()
84
    {
85
        return $this->job_id;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getPrevhash()
92
    {
93
        return $this->prevhash;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getCoinb1()
100
    {
101
        return $this->coinb1;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getCoinb2()
108
    {
109
        return $this->coinb2;
110
    }
111
112
    /**
113
     * @return array
114
     */
115
    public function getMerkleBranch()
116
    {
117
        return $this->merkle_branch;
118
    }
119
120
    /**
121
     * @return int
122
     */
123
    public function getVersion()
124
    {
125
        return $this->version;
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getBits()
132
    {
133
        return $this->nbits;
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function getTime()
140
    {
141
        return $this->ntime;
142
    }
143
144
    /**
145
     * @return boolean
146
     */
147
    public function isCleanJobs()
148
    {
149
        return $this->clean_jobs;
150
    }
151
152
    /**
153
     * @return Request
154
     */
155
    public function toRequest()
156
    {
157
        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