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

BitcoinCash   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 2
A getCashAddressPrefix() 0 3 1
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