Issues (193)

src/Api/Endpoint/BlogEndpoint.php (5 issues)

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 BlogEndpoint 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/blogs.json', $query);
18
        $response = $this->send($request);
19
        return $this->createCollection($response->get('blogs'));
0 ignored issues
show
It seems like $response->get('blogs') can also be of type string; however, parameter $items of CodeCloud\Bundle\Shopify...int::createCollection() 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 ignore-type  annotation

19
        return $this->createCollection(/** @scrutinizer ignore-type */ $response->get('blogs'));
Loading history...
20
    }
21
22
    /**
23
     * @return int
24
     */
25
    public function countAll()
26
    {
27
        $request = new GetJson('/admin/blogs/count.json');
28
        $response = $this->send($request);
29
        return $response->get('count');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $response->get('count') also could return the type string which is incompatible with the documented return type integer.
Loading history...
30
    }
31
32
    /**
33
     * @param int $blogId
34
     * @param array $fields
35
     * @return GenericResource
36
     */
37
    public function findOne($blogId, array $fields = array())
38
    {
39
        $params = $fields ? array('fields' => $fields) : array();
40
        $request = new GetJson('/admin/blogs/' . $blogId . '.json', $params);
41
        $response = $this->send($request);
42
        return $this->createEntity($response->get('blog'));
0 ignored issues
show
It seems like $response->get('blog') 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 ignore-type  annotation

42
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('blog'));
Loading history...
43
    }
44
45
    /**
46
     * @param GenericResource $blog
47
     * @return GenericResource
48
     */
49
    public function create(GenericResource $blog)
50
    {
51
        $request = new PostJson('/admin/blogs.json', array('blog' => $blog->toArray()));
52
        $response = $this->send($request);
53
        return $this->createEntity($response->get('blog'));
0 ignored issues
show
It seems like $response->get('blog') 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 ignore-type  annotation

53
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('blog'));
Loading history...
54
    }
55
56
    /**
57
     * @param int $blogId
58
     * @param GenericResource $blog
59
     * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource
60
     */
61
    public function update($blogId, GenericResource $blog)
62
    {
63
        $request = new PostJson('/admin/blogs/' . $blogId . '.json', array('blog' => $blog->toArray()));
64
        $response = $this->send($request);
65
        return $this->createEntity($response->get('blog'));
0 ignored issues
show
It seems like $response->get('blog') 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 ignore-type  annotation

65
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('blog'));
Loading history...
66
    }
67
68
    /**
69
     * @param int $blogId
70
     */
71
    public function delete($blogId)
72
    {
73
        $request = new DeleteParams('/admin/blogs/' . $blogId . '.json');
74
        $this->send($request);
75
    }
76
}
77