GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

OrderApi::listPerPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 11
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaignApi\Api;
7
8
use CommerceLeague\ActiveCampaignApi\Client\CommonResourceClientInterface;
9
use CommerceLeague\ActiveCampaignApi\Paginator\PageFactoryInterface;
10
use CommerceLeague\ActiveCampaignApi\Paginator\PageInterface;
11
use CommerceLeague\ActiveCampaignApi\Paginator\ResourceCursorFactoryInterface;
12
use CommerceLeague\ActiveCampaignApi\Paginator\ResourceCursorInterface;
13
14
/**
15
 * Class OrderApi
16
 */
17
class OrderApi implements OrderApiResourceInterface
18
{
19
    /**
20
     * @var CommonResourceClientInterface
21
     */
22
    private $resourceClient;
23
24
    /**
25
     * @var PageFactoryInterface
26
     */
27
    private $pageFactory;
28
29
    /**
30
     * @var ResourceCursorFactoryInterface
31
     */
32
    private $cursorFactory;
33
34
    /**
35
     * @param CommonResourceClientInterface $resourceClient
36
     * @param PageFactoryInterface $pageFactory
37
     * @param ResourceCursorFactoryInterface $cursorFactory
38
     */
39
    public function __construct(
40
        CommonResourceClientInterface $resourceClient,
41
        PageFactoryInterface $pageFactory,
42
        ResourceCursorFactoryInterface $cursorFactory
43
    ) {
44
        $this->resourceClient = $resourceClient;
45
        $this->pageFactory = $pageFactory;
46
        $this->cursorFactory = $cursorFactory;
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function get(int $id): array
53
    {
54
        return $this->resourceClient->getResource('api/3/ecomOrders/%s', [$id]);
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function listPerPage(int $limit = 100, int $offset = 0, array $queryParameters = []): PageInterface
61
    {
62
        $response = $this->resourceClient->getResources(
63
            'api/3/ecomOrders',
64
            [],
65
            $limit,
66
            $offset,
67
            $queryParameters
68
        );
69
70
        return $this->pageFactory->createPage($this, $response['ecomOrders'], $response['meta']);
71
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    public function all(int $limit = 100, array $queryParameters = []): ResourceCursorInterface
77
    {
78
        $firstPage = $this->listPerPage($limit, 0, $queryParameters);
79
        return $this->cursorFactory->createCursor($limit, $firstPage);
80
    }
81
82
    /**
83
     * @inheritDoc
84
     */
85
    public function create(array $data): array
86
    {
87
        return $this->resourceClient->createResource('api/3/ecomOrders', [], $data);
88
    }
89
90
    /**
91
     * @inheritDoc
92
     */
93
    public function update(int $id, array $data = []): array
94
    {
95
        return $this->resourceClient->updateResource('api/3/ecomOrders/%s', [$id], $data);
96
    }
97
98
    /**
99
     * @inheritDoc
100
     */
101
    public function delete(int $id): bool
102
    {
103
        return $this->resourceClient->deleteResource('api/3/ecomOrders/%s', [$id]);
104
    }
105
}
106