Passed
Push — master ( 365cfc...8e997c )
by Mr
04:36
created

BitcoinBlock::getTimestamp()   A

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 3
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\EntityInterface;
14
use Daikon\Entity\EntityTrait;
15
use Daikon\ValueObject\IntValue;
16
use Daikon\ValueObject\Timestamp;
0 ignored issues
show
Bug introduced by
The type Daikon\ValueObject\Timestamp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use NGUtech\Bitcoin\ValueObject\Hash;
18
use NGUtech\Bitcoin\ValueObject\HashList;
19
20
final class BitcoinBlock implements EntityInterface
21
{
22
    use EntityTrait;
23
24
    public static function getAttributeMap(): AttributeMap
25
    {
26
        return new AttributeMap([
27
            Attribute::define('hash', Hash::class),
28
            Attribute::define('merkleRoot', Hash::class),
29
            Attribute::define('confirmations', IntValue::class),
30
            Attribute::define('transactions', HashList::class),
31
            Attribute::define('height', IntValue::class),
32
            Attribute::define('timestamp', Timestamp::class)
33
        ]);
34
    }
35
36
    public function getIdentity(): Hash
37
    {
38
        return $this->getHash();
39
    }
40
41
    public function getHash(): Hash
42
    {
43
        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...
44
    }
45
46
    public function getMerkleRoot(): Hash
47
    {
48
        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...
49
    }
50
51
    public function getConfirmations(): IntValue
52
    {
53
        return $this->get('confirmations') ?? IntValue::zero();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('confi...Object\IntValue::zero() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\IntValue. Consider adding an additional type-check to rule them out.
Loading history...
54
    }
55
56
    public function getTransactions(): HashList
57
    {
58
        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 is incompatible with the type-hinted return NGUtech\Bitcoin\ValueObject\HashList. Consider adding an additional type-check to rule them out.
Loading history...
59
    }
60
61
    public function getHeight(): IntValue
62
    {
63
        return $this->get('height') ?? IntValue::zero();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('heigh...Object\IntValue::zero() could return the type Daikon\ValueObject\ValueObjectInterface which includes types incompatible with the type-hinted return Daikon\ValueObject\IntValue. Consider adding an additional type-check to rule them out.
Loading history...
64
    }
65
66
    public function getTimestamp(): Timestamp
67
    {
68
        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 is incompatible with the type-hinted return Daikon\ValueObject\Timestamp. Consider adding an additional type-check to rule them out.
Loading history...
69
    }
70
}
71