Completed
Pull Request — master (#2)
by thomas
01:56
created

DeviceListResponse::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.6666
cc 3
eloc 4
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Trezor\Bridge\Message;
6
7
abstract class DeviceListResponse
8
{
9
    /**
10
     * @var Device[]
11
     */
12
    private $devices = [];
13
14
    /**
15
     * @param Device[] $devices
16
     */
17 3
    public function __construct(array $devices)
18
    {
19 3
        foreach ($devices as $device) {
20 3
            if (!($device instanceof Device)) {
21 3
                throw new \InvalidArgumentException();
22
            }
23
        }
24
25 3
        $this->devices = $devices;
26 3
    }
27
28
    /**
29
     * @return Device[]
30
     */
31 3
    public function devices(): array
32
    {
33 3
        return $this->devices;
34
    }
35
}
36