Completed
Pull Request — master (#248)
by
unknown
02:33
created

CustomerList   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 5 1
A getCustomers() 0 4 1
A get() 0 4 1
A populate() 0 9 1
1
<?php
2
3
namespace Moip\Resource;
4
5
use Moip\Helper\Filters;
6
use Moip\Helper\Pagination;
7
use stdClass;
8
9
class CustomerList extends MoipResource
10
{
11
    /**
12
     * @const string
13
     */
14
    const PATH = 'customers';
15
16
    /**
17
     * @const string
18
     */
19
    const CREATED_AT = 'createdAt';
20
21
    public function initialize()
22
    {
23
        $this->data = new stdClass();
24
        $this->data->customers = [];
25
    }
26
27
    /**
28
     * Get customers.
29
     *
30
     * @return array
31
     */
32
    public function getCustomers()
33
    {
34
        return $this->getIfSet('customers');
35
    }
36
37
    /**
38
     * Get an customer list in MoIP.
39
     *
40
     * @param Pagination $pagination
41
     * @param Filters    $filters
42
     * @param string     $qParam     Query a specific value.
43
     *
44
     * @return stdClass
45
     */
46
    public function get(Pagination $pagination = null, Filters $filters = null, $qParam = '')
47
    {
48
        return $this->getByPath($this->generateListPath($pagination, $filters, ['q' => $qParam]));
49
    }
50
51
    protected function populate(stdClass $response)
52
    {
53
        $customerList = clone $this;
54
        $customerList->data = new stdClass();
55
56
        $customerList->data->customers = $response->customers;
57
58
        return $customerList;
59
    }
60
}
61