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

CustomerList::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 1
b 0
f 0
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