Passed
Push — master ( 80a2af...b754d5 )
by Fabian
51s
created

TradableAssetPairsResponse::manualMapping()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 33
Code Lines 27

Duplication

Lines 10
Ratio 30.3 %

Code Coverage

Tests 32
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 27
nc 5
nop 1
dl 10
loc 33
ccs 32
cts 32
cp 1
crap 6
rs 8.439
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\TradableAssetPairs;
4
5
use HanischIt\KrakenApi\Call\TradableAssetPairs\Model\AssetPairModel;
6
use HanischIt\KrakenApi\Call\TradableAssetPairs\Model\FeeModel;
7
use HanischIt\KrakenApi\Model\ResponseInterface;
8
9
/**
10
 * Class TradableAssetPairsResponse
11
 * @package HanischIt\KrakenApi\Call\TradableAssetPairs
12
 */
13
class TradableAssetPairsResponse implements ResponseInterface
14
{
15
    /**
16
     * @var AssetPairModel[]
17
     */
18
    private $tradableAssets;
19
20
    /**
21
     * @param array $arr
22
     */
23 1
    public function manualMapping(array $arr)
24
    {
25 1
        foreach ($arr as $assetPair => $data) {
26 1
            $fees = [];
27 1 View Code Duplication
            if (isset($data["fees"])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28 1
                foreach ($data["fees"] as $feeData) {
29 1
                    $fees[] = new FeeModel($feeData[0], $feeData[1]);
30 1
                }
31 1
            }
32 1
            $feesMaker = [];
33 1 View Code Duplication
            if (isset($data["fees_maker"])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34 1
                foreach ($data["fees_maker"] as $feeData) {
35 1
                    $feesMaker[] = new FeeModel($feeData[0], $feeData[1]);
36 1
                }
37 1
            }
38 1
            $this->tradableAssets[] = new AssetPairModel(
39 1
                $assetPair,
40 1
                $data["altname"],
41 1
                $data["aclass_base"],
42 1
                $data["base"],
43 1
                $data["aclass_quote"],
44 1
                $data["quote"],
45 1
                $data["lot"],
46 1
                $data["pair_decimals"],
47 1
                $data["lot_decimals"],
48 1
                $data["lot_multiplier"],
49 1
                $data["leverage_buy"],
50 1
                $data["leverage_sell"],
51 1
                $fees,
52 1
                $feesMaker,
53 1
                $data["fee_volume_currency"],
54 1
                $data["margin_call"],
55 1
                $data["margin_stop"]
56 1
            );
57 1
        }
58 1
    }
59
60
    /**
61
     * @return AssetPairModel[]
62
     */
63 1
    public function getTradableAssets()
64
    {
65 1
        return $this->tradableAssets;
66
    }
67
}
68