Completed
Push — master ( 3ad417...37b5d9 )
by Fabian
02:10
created

RecentTradesAbstractRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getVisibility() 3 3 1
A __construct() 4 4 1
A getResponseClassName() 3 3 1
A getRequestData() 9 9 2
A getMethod() 3 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\Model\RecentTrades;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\AbstractRequest;
7
8
/**
9
 * Class RecentTradesAbstractRequest
10
 *
11
 * @package HanischIt\Model\RecentTrades
12
 */
13 View Code Duplication
class RecentTradesAbstractRequest extends AbstractRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
14
{
15
    /**
16
     * @var string
17
     */
18
    private $assetPair;
19
    /**
20
     * @var string
21
     */
22
    private $since;
23
24
    /**
25
     * RecentTradesAbstractRequest constructor.
26
     *
27
     * @param string $assetPair
28
     * @param string $since
29
     */
30 2
    public function __construct($assetPair, $since)
31
    {
32 2
        $this->assetPair = $assetPair;
33 2
        $this->since = $since;
34 2
    }
35
36
37
    /**
38
     * Returns the api request name
39
     *
40
     * @return string
41
     */
42 1
    public function getMethod()
43
    {
44 1
        return 'Trades';
45
    }
46
47
    /**
48
     * @return string
49
     */
50 1
    public function getVisibility()
51
    {
52 1
        return VisibilityEnum::VISIBILITY_PUBLIC;
53
    }
54
55
    /**
56
     * @return array
57
     */
58 1
    public function getRequestData()
59
    {
60 1
        $ret = [];
61 1
        $ret['pair'] = $this->assetPair;
62 1
        if ($this->since) {
63 1
            $ret['since'] = $this->since;
64 1
        }
65
66 1
        return $ret;
67
    }
68
69
    /**
70
     * @return string
71
     */
72 1
    public function getResponseClassName()
73
    {
74 1
        return RecentTradesResponse::class;
75
    }
76
}
77