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

DeviceListResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A devices() 0 3 1
A count() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Trezor\Bridge\Message;
6
7
abstract class DeviceListResponse implements \Countable
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 1
    public function count(): int
29
    {
30 1
        return count($this->devices);
31
    }
32
33
    /**
34
     * @return Device[]
35
     */
36 3
    public function devices(): array
37
    {
38 3
        return $this->devices;
39
    }
40
}
41