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

TradableAssetPairsResponse   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 18.87 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 10
loc 53
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
B manualMapping() 10 33 6
A getTradableAssets() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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