Completed
Push — master ( 4517c4...dc88ca )
by
unknown
05:54
created

BankAccountList   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 57
loc 57
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 4 4 1
A getBankAccounts() 4 4 1
A get() 4 4 1
A populate() 10 10 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 Moip\Resource;
4
5
use stdClass;
6
7 View Code Duplication
class BankAccountList extends MoipResource
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...
8
{
9
    /**
10
     * Path bank accounts API.
11
     *
12
     * @const string
13
     */
14
    const PATH = 'bankaccounts';
15
16
    /**
17
     * Path accounts API.
18
     *
19
     * @const string
20
     */
21
    const PATH_ACCOUNT = 'accounts';
22
23
    /**
24
     * Initialize a new instance.
25
     */
26
    public function initialize()
27
    {
28
        $this->data = new stdClass();
29
    }
30
31
    /**
32
     * Get bank accounts.
33
     *
34
     * @return array
35
     */
36
    public function getBankAccounts()
37
    {
38
        return $this->data->bankAccounts;
39
    }
40
41
    /**
42
     * Get a bank accounts list.
43
     *
44
     * @param string Account id.
45
     *
46
     * @return stdClass
47
     */
48
    public function get($account_id)
49
    {
50
        return $this->getByPath(sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH_ACCOUNT, $account_id, self::PATH));
51
    }
52
53
    protected function populate(stdClass $response)
54
    {
55
        $bankAccountsList = clone $this;
56
57
        $bankAccountsList->data = new stdClass();
58
59
        $bankAccountsList->data->bankAccounts = $response;
60
61
        return $bankAccountsList;
62
    }
63
}
64