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

Operation::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace BitWasp\Bitcoin\Script\Parser;
4
5
use BitWasp\Bitcoin\Script\Opcodes;
6
use BitWasp\Buffertools\Buffer;
7
8
class Operation
9
{
10
    /**
11
     * @var bool
12
     */
13
    private $push;
14
15
    /**
16
     * @var int
17
     */
18
    private $opCode;
19
20
    /**
21
     * @var Buffer|null
22
     */
23
    private $pushData;
24
25
    /**
26
     * ScriptExec constructor.
27
     * @param $opCode
28
     * @param Buffer|null $pushData
29
     */
30 1035
    public function __construct($opCode, Buffer $pushData = null)
31
    {
32 1035
        $this->push = $opCode >= 0 && $opCode <= Opcodes::OP_PUSHDATA4;
33 1035
        $this->opCode = $opCode;
34 1035
        $this->pushData = $pushData;
35 1035
    }
36
37
    /**
38
     * @return bool
39
     */
40 90
    public function isPush()
41
    {
42 90
        return $this->push;
43
    }
44
45
    /**
46
     * @return int
47
     */
48 993
    public function getOp()
49
    {
50 993
        return $this->opCode;
51
    }
52
53
    /**
54
     * @return Buffer|null
55
     */
56 987
    public function getData()
57
    {
58 987
        return $this->pushData;
59
    }
60
}
61