Completed
Push — master ( c7419f...b9ebc8 )
by thomas
35:04 queued 31:19
created

P2shScriptFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 1
cbo 2
dl 0
loc 49
ccs 5
cts 9
cp 0.5556
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A multisig() 0 4 1
A payToPubKey() 0 4 1
A payToPubKeyHash() 0 4 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Script\Factory;
4
5
use BitWasp\Bitcoin\Script\P2shScript;
6
use BitWasp\Bitcoin\Crypto\EcAdapter\Key\PublicKeyInterface;
7
8
class P2shScriptFactory
9
{
10
    /**
11
     * @var OutputScriptFactory
12
     */
13
    private $scriptPubKey;
14
15
    /**
16
     * P2shScriptFactory constructor.
17
     * @param OutputScriptFactory $scriptPubKey
18
     */
19 6
    public function __construct(OutputScriptFactory $scriptPubKey)
20
    {
21 6
        $this->scriptPubKey = $scriptPubKey;
22 6
    }
23
24
    /**
25
     * Create a multisig redeemScript and outputScript
26
     *
27
     * @param $m
28
     * @param array $keys
29
     * @param bool|true $sort
30
     * @return P2shScript
31
     */
32 6
    public function multisig($m, array $keys, $sort = true)
33
    {
34 6
        return new P2shScript($this->scriptPubKey->multisig($m, $keys, $sort));
35
    }
36
37
    /**
38
     * Create a Pay to pubkey redeemScript and outputScript
39
     * @param PublicKeyInterface  $publicKey
40
     * @return P2shScript
41
     */
42
    public function payToPubKey(PublicKeyInterface $publicKey)
43
    {
44
        return new P2shScript($this->scriptPubKey->payToPubKey($publicKey));
45
    }
46
47
    /**
48
     * Create a Pay to pubkey-hash redeemScript and outputScript
49
     * @param PublicKeyInterface  $publicKey
50
     * @return P2shScript
51
     */
52
    public function payToPubKeyHash(PublicKeyInterface $publicKey)
53
    {
54
        return new P2shScript($this->scriptPubKey->payToPubKeyHash($publicKey));
55
    }
56
}
57