Completed
Push — master ( bd4ff0...d83768 )
by Fabian
03:55
created

TradableAssetPairsResponse::manualMapping()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 29
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 25
nc 5
nop 1
dl 0
loc 29
ccs 0
cts 29
cp 0
crap 20
rs 8.5806
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\TradableAssetPairs;
4
5
use HanischIt\KrakenApi\Model\ResponseInterface;
6
7
/**
8
 * Class TradableAssetPairsResponse
9
 * @package HanischIt\KrakenApi\Model\TradableAssetPairs
10
 */
11
class TradableAssetPairsResponse implements ResponseInterface
12
{
13
    /**
14
     * @var AssetPairModel[]
15
     */
16
    private $tradableAssets;
17
18
    /**
19
     * @param array $arr
20
     */
21
    public function manualMapping(array $arr)
22
    {
23
        foreach ($arr as $assetPair => $data) {
24
            $fees = [];
25
            foreach ($data["fees"] as $feeData) {
26
                $fees[] = new FeeModel($feeData[0], $feeData[1]);
27
            }
28
            $feesMaker = [];
29
            foreach ($data["fees_maker"] as $feeData) {
30
                $feesMaker[] = new FeeModel($feeData[0], $feeData[1]);
31
            }
32
            $this->tradableAssets[] = new AssetPairModel(
33
                $assetPair,
34
                $data["altname"],
35
                $data["aclass_base"],
36
                $data["base"],
37
                $data["aclass_quote"],
38
                $data["quote"],
39
                $data["lot"],
40
                $data["pair_decimals"],
41
                $data["lot_decimals"],
42
                $data["lot_multiplier"],
43
                $data["leverage_buy"],
44
                $data["leverage_sell"],
45
                $fees,
0 ignored issues
show
Bug introduced by
$fees of type HanischIt\KrakenApi\Mode...tPairs\FeeModel[]|array is incompatible with the type string expected by parameter $fees of HanischIt\KrakenApi\Mode...airModel::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
                /** @scrutinizer ignore-type */ $fees,
Loading history...
46
                $feesMaker,
0 ignored issues
show
Bug introduced by
$feesMaker of type HanischIt\KrakenApi\Mode...tPairs\FeeModel[]|array is incompatible with the type string expected by parameter $feesMaker of HanischIt\KrakenApi\Mode...airModel::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
                /** @scrutinizer ignore-type */ $feesMaker,
Loading history...
47
                $data["fee_volume_currency"],
48
                $data["margin_call"],
49
                $data["margin_stop"]
50
            );
51
        }
52
    }
53
54
    /**
55
     * @return AssetPairModel[]
56
     */
57
    public function getTradableAssets()
58
    {
59
        return $this->tradableAssets;
60
    }
61
}
62