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

DeviceListResponse::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 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