Completed
Push — master ( df95c6...f74e51 )
by
unknown
13s
created

OrdersList   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 5 1
A getOrders() 0 4 1
A get() 0 4 1
A populate() 0 12 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 OrdersList extends MoipResource
10
{
11
    /**
12
     * @const string
13
     */
14
    const PATH = 'orders';
15
16
    /**
17
     * @const string
18
     */
19
    const CREATED_AT = 'createdAt';
20
21
    /**
22
     * @const string
23
     */
24
    const PAYMENT_METHOD = 'paymentMethod';
25
26
    /**
27
     * @const string
28
     */
29
    const VALUE = 'value';
30
31
    /**
32
     * @const string
33
     */
34
    const STATUS = 'status';
35
36
    public function initialize()
37
    {
38
        $this->data = new stdClass();
39
        $this->data->orders = [];
40
    }
41
42
    /**
43
     * Get orders.
44
     *
45
     * @return array
46
     */
47
    public function getOrders()
48
    {
49
        return $this->getIfSet('orders');
50
    }
51
52
    /**
53
     * Get an order list in MoIP.
54
     *
55
     * @param Pagination $pagination
56
     * @param Filters    $filters
57
     * @param string     $qParam     Query a specific value.
58
     *
59
     * @return stdClass
60
     */
61
    public function get(Pagination $pagination = null, Filters $filters = null, $qParam = '')
62
    {
63
        return $this->getByPath($this->generateListPath($pagination, $filters, $qParam));
64
    }
65
66
    protected function populate(stdClass $response)
67
    {
68
        $ordersList = clone $this;
69
        $ordersList->data = new stdClass();
70
71
        $ordersList->data->orders = $response->orders;
72
73
        $ordersList->data->summary = $response->summary;
74
        $ordersList->_links = $response->_links;
0 ignored issues
show
Bug introduced by
The property _links does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
75
76
        return $ordersList;
77
    }
78
}
79