Completed
Push — master ( d80e29...4963c9 )
by thomas
26:06
created

TransactionOutput::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
cc 1
eloc 6
nc 1
nop 2
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 $value
28
     * @param ScriptInterface $script
29
     */
30 537
    public function __construct($value, ScriptInterface $script)
31
    {
32
33 537
        $this->value = $value;
34 537
        $this->script = $script;
35 537
        $this
36 537
            ->initFunctionAlias('value', 'getValue')
37 537
            ->initFunctionAlias('script', 'getScript');
38 537
    }
39
40
    /**
41
     * @return void
42
     */
43
    public function __clone()
44
    {
45
        $this->script = clone $this->script;
46
    }
47
48
    /**
49
     * @see TransactionOutputInterface::getValue()
50
     */
51 423
    public function getValue()
52
    {
53 423
        return $this->value;
54
    }
55
56
    /**
57
     * @see TransactionOutputInterface::getScript()
58
     */
59 423
    public function getScript()
60
    {
61 423
        return $this->script;
62
    }
63
64
    /**
65
     * @see \BitWasp\Bitcoin\SerializableInterface::getBuffer()
66
     */
67 351
    public function getBuffer()
68
    {
69 351
        return (new TransactionOutputSerializer())->serialize($this);
70
    }
71
}
72