Alert::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Networking\Messages;
6
7
use BitWasp\Bitcoin\Crypto\EcAdapter\Signature\SignatureInterface;
8
use BitWasp\Bitcoin\Networking\Message;
9
use BitWasp\Bitcoin\Networking\NetworkSerializable;
10
use BitWasp\Bitcoin\Networking\Serializer\Message\AlertSerializer;
11
use BitWasp\Bitcoin\Networking\Serializer\Structure\AlertDetailSerializer;
12
use BitWasp\Bitcoin\Networking\Structure\AlertDetail;
13
use BitWasp\Buffertools\BufferInterface;
14
15
class Alert extends NetworkSerializable
16
{
17
    /**
18
     * @var AlertDetail
19
     */
20
    private $alert;
21
22
    /**
23
     * @var SignatureInterface
24
     */
25
    private $signature;
26
27
    /**
28 3
     * @param AlertDetail $alert
29
     * @param SignatureInterface $signature
30 3
     */
31 3
    public function __construct(AlertDetail $alert, SignatureInterface $signature)
32 3
    {
33
        $this->alert = $alert;
34
        $this->signature = $signature;
35
    }
36
37 3
    /**
38
     * @return string
39 3
     * @see https://en.bitcoin.it/wiki/Protocol_documentation#alert
40
     */
41
    public function getNetworkCommand(): string
42
    {
43
        return Message::ALERT;
44
    }
45 3
46
    /**
47 3
     * @return AlertDetail
48
     */
49
    public function getDetail(): AlertDetail
50
    {
51
        return $this->alert;
52
    }
53 3
54
    /**
55 3
     * @return SignatureInterface
56
     */
57
    public function getSignature(): SignatureInterface
58
    {
59
        return $this->signature;
60
    }
61
62 3
    /**
63
     * @see \BitWasp\Bitcoin\SerializableInterface::getBuffer()
64 3
     * @return BufferInterface
65
     */
66
    public function getBuffer(): BufferInterface
67
    {
68
        return (new AlertSerializer(new AlertDetailSerializer()))->serialize($this);
69
    }
70
}
71