Tx::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Networking\Messages;
6
7
use BitWasp\Bitcoin\Networking\Message;
8
use BitWasp\Bitcoin\Networking\NetworkSerializable;
9
use BitWasp\Buffertools\BufferInterface;
10
11
class Tx extends NetworkSerializable
12
{
13
    /**
14
     * Tx describes a bitcoin transaction, in reply to getdata
15
     *
16
     * @var BufferInterface
17
     */
18
    private $transaction;
19 6
20
    public function __construct(BufferInterface $tx)
21 6
    {
22 6
        $this->transaction = $tx;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     * @see https://en.bitcoin.it/wiki/Protocol_documentation#tx
28 6
     * @see \BitWasp\Bitcoin\Network\NetworkSerializableInterface::getNetworkCommand()
29
     */
30 6
    public function getNetworkCommand(): string
31
    {
32
        return Message::TX;
33
    }
34
35
    /**
36 3
     * @return BufferInterface
37
     */
38 3
    public function getTransaction(): BufferInterface
39
    {
40
        return $this->transaction;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45 6
     * @see \BitWasp\Bitcoin\SerializableInterface::getBuffer()
46
     */
47 6
    public function getBuffer(): BufferInterface
48
    {
49
        return $this->transaction;
50
    }
51
}
52