Completed
Pull Request — master (#99)
by thomas
42:14 queued 39:21
created

BitcoinCash::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 16
nc 2
nop 1
dl 0
loc 21
ccs 16
cts 16
cp 1
crap 2
rs 9.3142
c 0
b 0
f 0
1
<?php
2
3
namespace Blocktrail\SDK\Network;
4
5
use BitWasp\Bitcoin\Network\Network;
6
use BitWasp\Bitcoin\Network\NetworkFactory;
7
8
class BitcoinCash extends Network implements BitcoinCashNetworkInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $cashAddressPrefix;
14
15
    /**
16
     * BitcoinCash constructor.
17
     * @param bool $testnet
18
     * @throws \Exception
19
     */
20 13
    public function __construct($testnet = false) {
21 13
        if ($testnet) {
22 8
            $base = NetworkFactory::bitcoinTestnet();
23 8
            $cashAddressPrefix = "bchtest";
24
        } else {
25 5
            $base = NetworkFactory::bitcoin();
26 5
            $cashAddressPrefix = "bitcoincash";
27
        }
28
29 13
        parent::__construct(
30 13
            $base->getAddressByte(),
31 13
            $base->getP2shByte(),
32 13
            $base->getPrivByte(),
33 13
            $base->isTestnet()
34
        );
35
36 13
        $this->setHDPrivByte($base->getHDPrivByte());
37 13
        $this->setHDPubByte($base->getHDPubByte());
38 13
        $this->setNetMagicBytes($base->getNetMagicBytes());
39 13
        $this->cashAddressPrefix = $cashAddressPrefix;
40 13
    }
41
42
    /**
43
     * @return string
44
     */
45 9
    public function getCashAddressPrefix() {
46 9
        return $this->cashAddressPrefix;
47
    }
48
}
49