Failed Conditions
Push — master ( ba8c0d...a9ded0 )
by thomas
04:50
created

GetEntropyService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 17
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 15 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Trezor\Device\Command;
6
7
use BitWasp\Trezor\Bridge\Session;
8
use BitWasp\Trezor\Device\Exception\UnexpectedResultException;
9
use BitWasp\Trezor\Device\Message;
10
use BitWasp\TrezorProto\ButtonRequest;
11
use BitWasp\TrezorProto\ButtonRequestType;
12
use BitWasp\TrezorProto\Entropy;
13
use BitWasp\TrezorProto\GetEntropy;
14
15
class GetEntropyService extends DeviceService
16
{
17
    public function call(
18
        Session $session,
19
        GetEntropy $getEntropy
20
    ): Entropy {
21
22
        $proto = $session->sendMessage(Message::getEntropy($getEntropy));
23
        if ($proto instanceof ButtonRequest) {
24
            $proto = $session->sendMessage($this->confirmWithButton($proto, ButtonRequestType::ButtonRequest_ProtectCall()));
25
        }
26
27
        if (!($proto instanceof Entropy)) {
28
            throw new UnexpectedResultException("Unexpected message returned, expecting Entropy");
29
        }
30
31
        return $proto;
32
    }
33
}
34