Completed
Pull Request — master (#239)
by thomas
31:39 queued 14:06
created

WitnessProgram   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 61.53%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 1
cbo 2
dl 0
loc 50
ccs 8
cts 13
cp 0.6153
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getVersion() 0 4 1
A getProgram() 0 4 1
A getScript() 0 7 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Script;
4
5
use BitWasp\Buffertools\BufferInterface;
6
7
class WitnessProgram
8
{
9
    /**
10
     * @var int
11
     */
12
    private $version;
13
14
    /**
15
     * @var BufferInterface
16
     */
17
    private $program;
18
19
    /**
20
     * WitnessProgram constructor.
21
     * @param int $version
22
     * @param BufferInterface $program
23
     */
24 30
    public function __construct($version, BufferInterface $program)
25
    {
26 30
        $this->version = $version;
27 30
        $this->program = $program;
28 30
    }
29
30
    /**
31
     * @return int
32
     */
33 30
    public function getVersion()
34
    {
35 30
        return $this->version;
36
    }
37
38
    /**
39
     * @return BufferInterface
40
     */
41 30
    public function getProgram()
42
    {
43 30
        return $this->program;
44
    }
45
46
    /**
47
     * @return ScriptInterface
48
     */
49
    public function getScript()
50
    {
51
        return ScriptFactory::create()
52
            ->int($this->version)
53
            ->push($this->program)
54
            ->getScript();
55
    }
56
}
57