Completed
Push — master ( 40a4e1...e12674 )
by thomas
37:14 queued 34:53
created

ScriptBranch   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 58
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getPath() 0 4 1
A getScriptSections() 0 4 1
A getOps() 0 8 2
1
<?php
2
3
namespace BitWasp\Bitcoin\Script\Path;
4
5
use BitWasp\Bitcoin\Script\ScriptInterface;
6
7
class ScriptBranch
8
{
9
    /**
10
     * @var ScriptInterface
11
     */
12
    private $fullScript;
13
14
    /**
15
     * @var array|\array[]
16
     */
17
    private $scriptSections;
18
19
    /**
20
     * @var array|\bool[]
21
     */
22
    private $branch;
23
24
    /**
25
     * ScriptBranch constructor.
26
     * @param ScriptInterface $fullScript
27
     * @param array $logicalPath
28
     * @param array $scriptSections
29
     */
30 180
    public function __construct(ScriptInterface $fullScript, array $logicalPath, array $scriptSections)
31
    {
32 180
        $this->fullScript = $fullScript;
33 180
        $this->branch = $logicalPath;
34 180
        $this->scriptSections = $scriptSections;
35 180
    }
36
37
    /**
38
     * @return array|\bool[]
39
     */
40 180
    public function getPath()
41
    {
42 180
        return $this->branch;
43
    }
44
45
    /**
46
     * @return array|\array[]
47
     */
48 174
    public function getScriptSections()
49
    {
50 174
        return $this->scriptSections;
51
    }
52
53
    /**
54
     * @return array
55
     */
56 38
    public function getOps()
57
    {
58 38
        $sequence = [];
59 38
        foreach ($this->getScriptSections() as $segment) {
60 36
            $sequence = array_merge($sequence, $segment);
61
        }
62 38
        return $sequence;
63
    }
64
}
65