Completed
Push — master ( a6a8a1...a2d76b )
by Fabian
06:14
created

LedgersInfoResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 27.66 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 13
loc 47
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCount() 0 3 1
A manualMapping() 11 15 2
A getLedgerInfos() 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\LedgersInfo;
4
5
use HanischIt\KrakenApi\Call\Shared\Model\LedgerInfoModel;
6
use HanischIt\KrakenApi\Model\ResponseInterface;
7
8
/**
9
 * Class LedgersInfoResponse
10
 * @package HanischIt\KrakenApi\Model\Trades
11
 */
12
class LedgersInfoResponse implements ResponseInterface
13
{
14
    /**
15
     * @var LedgerInfoModel[]
16
     */
17
    private $ledgerInfos;
18
    /**
19
     * @var int
20
     */
21
    private $count;
22
23
    /**
24
     * @param array $result
25
     */
26 1
    public function manualMapping($result)
27
    {
28 1
        $this->count = $result["count"];
29
30 1 View Code Duplication
        foreach ($result["ledger"] as $ledgerId => $ledger) {
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...
31 1
            $this->ledgerInfos[] = new LedgerInfoModel(
32 1
                $ledgerId,
33 1
                $ledger['refid'],
34 1
                $ledger['time'],
35 1
                $ledger['type'],
36 1
                $ledger['aclass'],
37 1
                $ledger['asset'],
38 1
                $ledger['amount'],
39 1
                $ledger['fee'],
40 1
                $ledger['balance']
41 1
            );
42 1
        }
43 1
    }
44
45
    /**
46
     * @return LedgerInfoModel[]
47
     */
48 1
    public function getLedgerInfos()
49
    {
50 1
        return $this->ledgerInfos;
51
    }
52
53
    /**
54
     * @return int
55
     */
56 1
    public function getCount()
57
    {
58 1
        return $this->count;
59
    }
60
61
62
}
63