Completed
Push — master ( 838d3a...3b658f )
by thomas
22:41 queued 01:10
created

TransactionOutput::getScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Transaction;
4
5
use BitWasp\Bitcoin\Script\ScriptInterface;
6
use BitWasp\Bitcoin\Serializable;
7
use BitWasp\Bitcoin\Serializer\Transaction\TransactionOutputSerializer;
8
use BitWasp\CommonTrait\FunctionAliasArrayAccess;
9
10
class TransactionOutput extends Serializable implements TransactionOutputInterface
11
{
12
    use FunctionAliasArrayAccess;
13
14
    /**
15
     * @var string|int
16
     */
17
    private $value;
18
19
    /**
20
     * @var ScriptInterface
21
     */
22
    private $script;
23
24
    /**
25
     * Initialize class
26
     *
27
     * @param int|string $value
28
     * @param ScriptInterface $script
29
     */
30 483
    public function __construct($value, ScriptInterface $script)
31
    {
32 483
        $this->value = $value;
33 483
        $this->script = $script;
34 483
        $this
35 483
            ->initFunctionAlias('value', 'getValue')
36 483
            ->initFunctionAlias('script', 'getScript');
37 483
    }
38
39
    /**
40
     * @return void
41
     */
42
    public function __clone()
43
    {
44
        $this->script = clone $this->script;
45
    }
46
47
    /**
48
     * @see TransactionOutputInterface::getValue()
49
     */
50 369
    public function getValue()
51
    {
52 369
        return $this->value;
53
    }
54
55
    /**
56
     * @see TransactionOutputInterface::getScript()
57
     */
58 369
    public function getScript()
59
    {
60 369
        return $this->script;
61
    }
62
63
    /**
64
     * @see \BitWasp\Bitcoin\SerializableInterface::getBuffer()
65
     */
66 297
    public function getBuffer()
67
    {
68 297
        return (new TransactionOutputSerializer())->serialize($this);
69
    }
70
}
71