Balance   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 28.95 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
c 4
b 0
f 0
lcom 1
cbo 1
dl 11
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getBalanceForAccountId() 11 11 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 Thepixeldeveloper\Mondo\Client;
4
5
use Thepixeldeveloper\Mondo\ClientInterface;
6
use Thepixeldeveloper\Mondo\Response;
7
8
/**
9
 * Class Balance
10
 *
11
 * @package Thepixeldeveloper\Mondo\Client
12
 */
13
class Balance
14
{
15
    /**
16
     * Mondo client.
17
     *
18
     * @var ClientInterface
19
     */
20
    protected $client;
21
22
    /**
23
     * Accounts constructor.
24
     *
25
     * @param ClientInterface $client
26
     */
27
    public function __construct(ClientInterface $client)
28
    {
29
        $this->client = $client;
30
    }
31
32
    /**
33
     * Get the balance for an account id.
34
     *
35
     * @param string $accountId
36
     *
37
     * @return Response\Balance
38
     */
39 View Code Duplication
    public function getBalanceForAccountId($accountId)
0 ignored issues
show
Duplication introduced by
This method 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...
40
    {
41
        return $this->client->deserializeResponse(
42
            $this->client->get('/balance', [
43
                'query' => [
44
                    'account_id' => $accountId
45
                ]
46
            ]),
47
            Response\Balance::class
48
        );
49
    }
50
}
51