Completed
Pull Request — master (#364)
by thomas
21:20 queued 30s
created

SignedMessage::getCompactSignature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 4
cp 0.5
crap 1.125
rs 10
1
<?php
2
3
namespace BitWasp\Bitcoin\MessageSigner;
4
5
use BitWasp\Bitcoin\Crypto\EcAdapter\EcSerializer;
6
use BitWasp\Bitcoin\Crypto\EcAdapter\Serializer\Signature\CompactSignatureSerializerInterface;
7
use BitWasp\Bitcoin\Serializer\MessageSigner\SignedMessageSerializer;
8
use BitWasp\Bitcoin\Crypto\EcAdapter\Signature\CompactSignatureInterface;
9
10
class SignedMessage
11
{
12
13
    /**
14
     * @var string
15
     */
16
    private $message;
17
18
    /**
19
     * @var CompactSignatureInterface
20
     */
21
    private $compactSignature;
22
23
    /**
24
     * @param string $message
25
     * @param CompactSignatureInterface $signature
26
     */
27 6
    public function __construct($message, CompactSignatureInterface $signature)
28
    {
29 6
        $this->message = $message;
30 6
        $this->compactSignature = $signature;
31 6
    }
32
33
    /**
34
     * @return string
35
     */
36 6
    public function getMessage()
37
    {
38 6
        return $this->message;
39
    }
40
41
    /**
42
     * @return CompactSignatureInterface
43
     */
44 6
    public function getCompactSignature()
45
    {
46 6
        return $this->compactSignature;
47
    }
48
49
    /**
50
     * @return \BitWasp\Buffertools\BufferInterface
51
     */
52 1
    public function getBuffer()
53
    {
54 1
        $serializer = new SignedMessageSerializer(
55 1
            EcSerializer::getSerializer(CompactSignatureSerializerInterface::class)
56 1
        );
57 1
        return $serializer->serialize($this);
58
    }
59
}
60