Completed
Pull Request — master (#386)
by thomas
112:49 queued 42:55
created

SignData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 56
rs 10
wmc 6
lcom 2
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A p2sh() 0 5 1
A p2wsh() 0 5 1
A getRedeemScript() 0 8 2
A getWitnessScript() 0 8 2
1
<?php
2
3
namespace BitWasp\Bitcoin\Transaction\Factory;
4
5
use BitWasp\Bitcoin\Script\ScriptInterface;
6
7
class SignData
8
{
9
    /**
10
     * @var ScriptInterface
11
     */
12
    protected $redeemScript = null;
13
14
    /**
15
     * @var ScriptInterface
16
     */
17
    protected $witnessScript = null;
18
19
    /**
20
     * @param ScriptInterface $redeemScript
21
     * @return $this
22
     */
23
    public function p2sh(ScriptInterface $redeemScript)
24
    {
25
        $this->redeemScript = $redeemScript;
26
        return $this;
27
    }
28
29
    /**
30
     * @param ScriptInterface $witnessScript
31
     * @return $this
32
     */
33
    public function p2wsh(ScriptInterface $witnessScript)
34
    {
35
        $this->witnessScript = $witnessScript;
36
        return $this;
37
    }
38
39
    /**
40
     * @return ScriptInterface
41
     */
42
    public function getRedeemScript()
43
    {
44
        if (null === $this->redeemScript) {
45
            throw new \RuntimeException('Redeem script requested but not set');
46
        }
47
48
        return $this->redeemScript;
49
    }
50
51
    /**
52
     * @return ScriptInterface
53
     */
54
    public function getWitnessScript()
55
    {
56
        if (null === $this->witnessScript) {
57
            throw new \RuntimeException('Witness script requested but not set');
58
        }
59
60
        return $this->witnessScript;
61
    }
62
}
63