1 | <?php |
||||
2 | namespace CodeCloud\Bundle\ShopifyBundle\Api\Endpoint; |
||||
3 | |||||
4 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\GetJson; |
||||
5 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\PostJson; |
||||
6 | use CodeCloud\Bundle\ShopifyBundle\Api\Request\PutJson; |
||||
7 | use CodeCloud\Bundle\ShopifyBundle\Api\GenericResource; |
||||
8 | |||||
9 | class CommentEndpoint 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/comments.json', $query); |
||||
18 | $response = $this->sendPaged($request, 'comments'); |
||||
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/comments/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 $commentId |
||||
35 | * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource |
||||
36 | */ |
||||
37 | public function findOne($commentId) |
||||
38 | { |
||||
39 | $request = new GetJson('/admin/comments/' . $commentId . '.json'); |
||||
40 | $response = $this->send($request); |
||||
41 | return $this->createEntity($response->get('comment')); |
||||
0 ignored issues
–
show
It seems like
$response->get('comment') 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 \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource $comment |
||||
46 | * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource |
||||
47 | */ |
||||
48 | public function create(GenericResource $comment) |
||||
49 | { |
||||
50 | $request = new PostJson('/admin/comments.json', array('comment' => $comment->toArray())); |
||||
51 | $response = $this->send($request); |
||||
52 | return $this->createEntity($response->get('comment')); |
||||
0 ignored issues
–
show
It seems like
$response->get('comment') 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 $commentId |
||||
57 | * @param \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource $comment |
||||
58 | * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource |
||||
59 | */ |
||||
60 | public function update($commentId, GenericResource $comment) |
||||
61 | { |
||||
62 | $request = new PutJson('/admin/comments/' . $commentId . '.json', array('comment' => $comment->toArray())); |
||||
63 | $response = $this->send($request); |
||||
64 | return $this->createEntity($response->get('comment')); |
||||
0 ignored issues
–
show
It seems like
$response->get('comment') 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...
|
|||||
65 | } |
||||
66 | |||||
67 | /** |
||||
68 | * @param int $commentId |
||||
69 | */ |
||||
70 | public function markAsSpam($commentId) |
||||
71 | { |
||||
72 | $request = new PostJson('/admin/comments/' . $commentId . '/spam.json'); |
||||
73 | $this->send($request); |
||||
74 | } |
||||
75 | |||||
76 | /** |
||||
77 | * @param int $commentId |
||||
78 | */ |
||||
79 | public function markAsNotSpam($commentId) |
||||
80 | { |
||||
81 | $request = new PostJson('/admin/comments/' . $commentId . '/not_spam.json'); |
||||
82 | $this->send($request); |
||||
83 | } |
||||
84 | |||||
85 | /** |
||||
86 | * @param int $commentId |
||||
87 | */ |
||||
88 | public function approve($commentId) |
||||
89 | { |
||||
90 | $request = new PostJson('/admin/comments/' . $commentId . '/approve.json'); |
||||
91 | $this->send($request); |
||||
92 | } |
||||
93 | |||||
94 | /** |
||||
95 | * @param int $commentId |
||||
96 | */ |
||||
97 | public function remove($commentId) |
||||
98 | { |
||||
99 | $request = new PostJson('/admin/comments/' . $commentId . '/remove.json'); |
||||
100 | $this->send($request); |
||||
101 | } |
||||
102 | |||||
103 | /** |
||||
104 | * @param int $commentId |
||||
105 | */ |
||||
106 | public function restore($commentId) |
||||
107 | { |
||||
108 | $request = new PostJson('/admin/comments/' . $commentId . '/restore.json'); |
||||
109 | $this->send($request); |
||||
110 | } |
||||
111 | } |
||||
112 |