Completed
Push — master ( 1c8af5...5745ff )
by thomas
04:13 queued 02:50
created

Util   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A witnessProgram() 0 10 4
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: tk
5
 * Date: 9/25/17
6
 * Time: 2:20 PM
7
 */
8
9
namespace BitWasp\Test\Bech32;
10
11
12
class Util
13
{
14
    public static function witnessProgram($version, $program)
15
    {
16
        if ($version < 0 || $version > 16) {
17
            throw new \RuntimeException("Invalid version for witness program");
18
        }
19
20
        $version = pack("C", ($version > 0 ? (0x50 + $version) : 0));
21
        $length = pack("C", strlen($program));
22
23
        return unpack("H*", "{$version}{$length}{$program}")[1];
24
    }
25
}
26