1 | <?php |
||||
2 | namespace CodeCloud\Bundle\ShopifyBundle\Api\Endpoint; |
||||
3 | |||||
4 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\DeleteParams; |
||||
5 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\GetJson; |
||||
6 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\PostJson; |
||||
7 | use CodeCloud\Bundle\ShopifyBundle\Api\GenericResource; |
||||
8 | |||||
9 | class CollectEndpoint extends AbstractEndpoint |
||||
10 | { |
||||
11 | /** |
||||
12 | * @param array $query |
||||
13 | * @return array|GenericResource[] |
||||
14 | */ |
||||
15 | public function findAll(array $query = array()) |
||||
16 | { |
||||
17 | $request = new GetJson('/admin/collects.json', $query); |
||||
18 | $response = $this->sendPaged($request, 'collects'); |
||||
19 | return $this->createCollection($response); |
||||
20 | } |
||||
21 | |||||
22 | /** |
||||
23 | * @param array $query |
||||
24 | * @return int |
||||
25 | */ |
||||
26 | public function countAll(array $query = array()) |
||||
27 | { |
||||
28 | $request = new GetJson('/admin/collects/count.json', $query); |
||||
29 | $response = $this->send($request); |
||||
30 | return $response->get('count'); |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
31 | } |
||||
32 | |||||
33 | /** |
||||
34 | * @param int $collectId |
||||
35 | * @return GenericResource |
||||
36 | */ |
||||
37 | public function findOne($collectId) |
||||
38 | { |
||||
39 | $request = new GetJson('/admin/collects/' . $collectId . '.json'); |
||||
40 | $response = $this->send($request); |
||||
41 | return $this->createEntity($response->get('collect')); |
||||
0 ignored issues
–
show
It seems like
$response->get('collect') can also be of type string ; however, parameter $data of CodeCloud\Bundle\Shopify...ndpoint::createEntity() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
42 | } |
||||
43 | |||||
44 | /** |
||||
45 | * @param GenericResource $collect |
||||
46 | * @return GenericResource |
||||
47 | */ |
||||
48 | public function create(GenericResource $collect) |
||||
49 | { |
||||
50 | $request = new PostJson('/admin/collects.json', array('collect' => $collect->toArray())); |
||||
51 | $response = $this->send($request); |
||||
52 | return $this->createEntity($response->get('collect')); |
||||
0 ignored issues
–
show
It seems like
$response->get('collect') can also be of type string ; however, parameter $data of CodeCloud\Bundle\Shopify...ndpoint::createEntity() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
53 | } |
||||
54 | |||||
55 | /** |
||||
56 | * @param int $collectId |
||||
57 | */ |
||||
58 | public function delete($collectId) |
||||
59 | { |
||||
60 | $request = new DeleteParams('/admin/collects/' . $collectId . '.json'); |
||||
61 | $this->send($request); |
||||
62 | } |
||||
63 | } |
||||
64 |