BitcoinBlock::getMerkleRoot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the ngutech/bitcoin-interop project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace NGUtech\Bitcoin\Entity;
10
11
use Daikon\Entity\Attribute;
12
use Daikon\Entity\AttributeMap;
13
use Daikon\Entity\Entity;
14
use Daikon\ValueObject\Natural;
15
use Daikon\ValueObject\Timestamp;
16
use NGUtech\Bitcoin\ValueObject\Hash;
17
use NGUtech\Bitcoin\ValueObject\HashList;
18
19
final class BitcoinBlock extends Entity
20
{
21
    public static function getAttributeMap(): AttributeMap
22
    {
23
        return new AttributeMap([
24
            Attribute::define('hash', Hash::class),
25
            Attribute::define('merkleRoot', Hash::class),
26
            Attribute::define('confirmations', Natural::class),
27
            Attribute::define('transactions', HashList::class),
28
            Attribute::define('height', Natural::class),
29
            Attribute::define('timestamp', Timestamp::class)
30
        ]);
31
    }
32
33
    public function getIdentity(): Hash
34
    {
35
        return $this->getHash();
36
    }
37
38
    public function getHash(): Hash
39
    {
40
        return $this->get('hash') ?? Hash::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('hash'...bject\Hash::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return NGUtech\Bitcoin\ValueObject\Hash. Consider adding an additional type-check to rule them out.
Loading history...
41
    }
42
43
    public function getMerkleRoot(): Hash
44
    {
45
        return $this->get('merkleRoot') ?? Hash::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('merkl...bject\Hash::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return NGUtech\Bitcoin\ValueObject\Hash. Consider adding an additional type-check to rule them out.
Loading history...
46
    }
47
48
    public function getConfirmations(): Natural
49
    {
50
        return $this->get('confirmations') ?? Natural::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('confi...ct\Natural::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Natural. Consider adding an additional type-check to rule them out.
Loading history...
51
    }
52
53
    public function getTransactions(): HashList
54
    {
55
        return $this->get('transactions') ?? HashList::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('trans...t\HashList::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return NGUtech\Bitcoin\ValueObject\HashList. Consider adding an additional type-check to rule them out.
Loading history...
56
    }
57
58
    public function getHeight(): Natural
59
    {
60
        return $this->get('height') ?? Natural::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('heigh...ct\Natural::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Natural. Consider adding an additional type-check to rule them out.
Loading history...
61
    }
62
63
    public function getTimestamp(): Timestamp
64
    {
65
        return $this->get('timestamp') ?? Timestamp::makeEmpty();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('times...\Timestamp::makeEmpty() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\Timestamp. Consider adding an additional type-check to rule them out.
Loading history...
66
    }
67
}
68