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

Util   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A networkByCoinName() 0 10 3
A networkByCoinShortcut() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Trezor\Device;
6
7
use BitWasp\TrezorProto\CoinType;
8
use BitWasp\TrezorProto\Features;
9
10
class Util
11
{
12
    /**
13
     * @param string $coinName
14
     * @param Features $features
15
     * @return CoinType|null
16
     */
17
    public static function networkByCoinName(string $coinName, Features $features)
18
    {
19
        foreach ($features->getCoinsList() as $coinType) {
20
            /** @var CoinType $coinType */
21
            if ($coinType->getCoinName() === $coinName) {
22
                return $coinType;
23
            }
24
        }
25
26
        return null;
27
    }
28
29
    /**
30
     * @param string $shortcut
31
     * @param Features $coinTypes
32
     * @return CoinType|null
33
     */
34
    public static function networkByCoinShortcut(string $shortcut, Features $coinTypes)
35
    {
36
        foreach ($coinTypes->getCoinsList() as $coinType) {
37
            /** @var CoinType $coinType */
38
            if ($coinType->getCoinShortcut() === $shortcut) {
39
                return $coinType;
40
            }
41
        }
42
43
        return null;
44
    }
45
}
46