Completed
Push — master ( 26690c...ea008d )
by thomas
177:34 queued 174:51
created

SignData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 56
ccs 12
cts 14
cp 0.8571
rs 10
c 1
b 0
f 0
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 24
    public function p2sh(ScriptInterface $redeemScript)
24
    {
25 24
        $this->redeemScript = $redeemScript;
26 24
        return $this;
27
    }
28
29
    /**
30
     * @param ScriptInterface $witnessScript
31
     * @return $this
32
     */
33 18
    public function p2wsh(ScriptInterface $witnessScript)
34
    {
35 18
        $this->witnessScript = $witnessScript;
36 18
        return $this;
37
    }
38
39
    /**
40
     * @return ScriptInterface
41
     */
42 24
    public function getRedeemScript()
43
    {
44 24
        if (null === $this->redeemScript) {
45
            throw new \RuntimeException('Redeem script requested but not set');
46
        }
47
48 24
        return $this->redeemScript;
49
    }
50
51
    /**
52
     * @return ScriptInterface
53
     */
54 18
    public function getWitnessScript()
55
    {
56 18
        if (null === $this->witnessScript) {
57
            throw new \RuntimeException('Witness script requested but not set');
58
        }
59
60 18
        return $this->witnessScript;
61
    }
62
}
63