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

P2shScript   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 5
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getOutputScript() 0 4 1
A getAddress() 0 4 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Script;
4
5
use BitWasp\Bitcoin\Address\AddressFactory;
6
use BitWasp\Bitcoin\Network\NetworkInterface;
7
8
class P2shScript extends Script
9
{
10
11
    /**
12
     * @var ScriptInterface
13
     */
14
    private $outputScript;
15
16
    /**
17
     * P2shScript constructor.
18
     * @param ScriptInterface $script
19
     * @param Opcodes|null $opcodes
20
     */
21 6
    public function __construct(ScriptInterface $script, Opcodes $opcodes = null)
22
    {
23 6
        parent::__construct($script->getBuffer(), $opcodes);
24 6
        $this->outputScript = ScriptFactory::scriptPubKey()->payToScriptHash($script);
25 6
    }
26
27
    /**
28
     * @return ScriptInterface
29
     */
30 6
    public function getOutputScript()
31
    {
32 6
        return $this->outputScript;
33
    }
34
35
    /**
36
     * @return \BitWasp\Bitcoin\Address\ScriptHashAddress
37
     */
38 6
    public function getAddress()
39
    {
40 6
        return AddressFactory::fromScript($this);
41
    }
42
}
43