Completed
Pull Request — master (#517)
by thomas
73:24
created

SegwitAddress::getAddress()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace BitWasp\Bitcoin\Address;
4
5
use BitWasp\Bitcoin\Bitcoin;
6
use BitWasp\Bitcoin\Network\NetworkInterface;
7
use BitWasp\Bitcoin\Script\WitnessProgram;
8
9
class SegwitAddress extends Address implements Bech32AddressInterface
0 ignored issues
show
Bug introduced by
There is one abstract method getScriptPubKey in this class; you could implement it, or declare this class as abstract.
Loading history...
10
{
11
    /**
12
     * @var WitnessProgram
13
     */
14
    protected $witnessProgram;
15
16
    /**
17
     * SegwitAddress constructor.
18
     * @param WitnessProgram $witnessProgram
19
     */
20
    public function __construct(WitnessProgram $witnessProgram)
21
    {
22
        $this->witnessProgram = $witnessProgram;
23
24
        parent::__construct($witnessProgram->getProgram());
25
    }
26
27
    /**
28
     * @param NetworkInterface|null $network
29
     * @return bool
30
     */
31
    public function getHRP(NetworkInterface $network = null)
32
    {
33
        $network = $network ?: Bitcoin::getNetwork();
34
        return $network->getSegwitBech32Prefix();
35
    }
36
37
    /**
38
     * @param NetworkInterface|null $network
39
     * @return string
40
     */
41
    public function getAddress(NetworkInterface $network = null)
42
    {
43
        $network = $network ?: Bitcoin::getNetwork();
0 ignored issues
show
Unused Code introduced by
$network is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
44
45
        return SegwitBech32::encode($this->witnessProgram);
46
    }
47
}
48