Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | 97 | public function __construct($version, BufferInterface $program) |
|
32 | { |
||
33 | 97 | if (self::V0 === $version) { |
|
34 | 96 | $size = $program->getSize(); |
|
35 | 96 | if ($size === 20) { |
|
36 | 19 | $this->script = ScriptFactory::scriptPubKey()->p2wkh($program); |
|
37 | 77 | } else if ($size === 32) { |
|
38 | 76 | $this->script = ScriptFactory::scriptPubKey()->p2wsh($program); |
|
39 | } else { |
||
40 | 96 | throw new \RuntimeException('Invalid size for V0 witness program - must be 20 or 32 bytes'); |
|
41 | } |
||
42 | } else { |
||
43 | 1 | throw new \InvalidArgumentException('Invalid witness version'); |
|
44 | } |
||
45 | |||
46 | 95 | $this->version = $version; |
|
47 | 95 | $this->program = $program; |
|
48 | 95 | } |
|
49 | |||
83 |