Completed
Pull Request — master (#241)
by thomas
133:23 queued 63:06
created

WitnessProgram   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

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
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 getOutputScript() 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
    public function __construct($version, BufferInterface $program)
25
    {
26
        $this->version = $version;
27
        $this->program = $program;
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function getVersion()
34
    {
35
        return $this->version;
36
    }
37
38
    /**
39
     * @return BufferInterface
40
     */
41
    public function getProgram()
42
    {
43
        return $this->program;
44
    }
45
46
    /**
47
     * @return ScriptInterface
48
     */
49
    public function getOutputScript()
50
    {
51
        return ScriptFactory::create()
52
            ->int($this->version)
53
            ->push($this->program)
54
            ->getScript();
55
    }
56
}
57