Completed
Pull Request — master (#2)
by thomas
02:17
created

InitializeService::call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 2
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\Message;
9
use BitWasp\TrezorProto\Features;
10
use BitWasp\TrezorProto\Initialize;
11
12
class InitializeService extends DeviceService
13
{
14 2
    public function call(
15
        Session $session,
16
        Initialize $initialize
17
    ): Features {
18 2
        $proto = $session->sendMessage(Message::initialize($initialize));
19 2
        if (!($proto instanceof Features)) {
20 1
            throw new \RuntimeException("Unexpected response, expecting Features, got " . get_class($proto));
21
        }
22
23 1
        return $proto;
24
    }
25
}
26