Completed
Push — master ( 2f17ad...d737aa )
by Morten Poul
39s queued 20s
created

ManagesOnlineStore::getPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Signifly\Shopify\REST\Actions;
4
5
use Illuminate\Support\Collection;
6
use Signifly\Shopify\REST\Cursor;
7
use Signifly\Shopify\REST\Resources\ApiResource;
8
use Signifly\Shopify\REST\Resources\ArticleResource;
9
use Signifly\Shopify\REST\Resources\BlogResource;
10
use Signifly\Shopify\REST\Resources\PageResource;
11
use Signifly\Shopify\Shopify;
12
13
/** @mixin Shopify */
14
trait ManagesOnlineStore
15
{
16
    public function createRedirect(string $path, string $target): ApiResource
17
    {
18
        return $this->createResource('redirects', [
0 ignored issues
show
Bug introduced by
The method createResource() does not exist on Signifly\Shopify\REST\Actions\ManagesOnlineStore. Did you maybe mean createRedirect()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return $this->/** @scrutinizer ignore-call */ createResource('redirects', [

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
            'path' => $path,
20
            'target' => $target,
21
        ]);
22
    }
23
24
    public function getRedirectsCount(array $params = []): int
25
    {
26
        return $this->getResourceCount('redirects', $params);
0 ignored issues
show
Bug introduced by
It seems like getResourceCount() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return $this->/** @scrutinizer ignore-call */ getResourceCount('redirects', $params);
Loading history...
27
    }
28
29
    public function paginateRedirects(array $params = []): Cursor
30
    {
31
        return $this->cursor($this->getRedirects($params));
0 ignored issues
show
Bug introduced by
It seems like cursor() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        return $this->/** @scrutinizer ignore-call */ cursor($this->getRedirects($params));
Loading history...
32
    }
33
34
    public function getRedirects(array $params = []): Collection
35
    {
36
        return $this->getResources('redirects', $params);
0 ignored issues
show
Bug introduced by
It seems like getResources() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        return $this->/** @scrutinizer ignore-call */ getResources('redirects', $params);
Loading history...
37
    }
38
39
    public function getRedirect($redirectId): ApiResource
40
    {
41
        return $this->getResource('redirects', $redirectId);
0 ignored issues
show
Bug introduced by
It seems like getResource() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        return $this->/** @scrutinizer ignore-call */ getResource('redirects', $redirectId);
Loading history...
42
    }
43
44
    public function updateRedirect($redirectId, $data): ApiResource
45
    {
46
        return $this->updateResource('redirects', $redirectId, $data);
0 ignored issues
show
Bug introduced by
The method updateResource() does not exist on Signifly\Shopify\REST\Actions\ManagesOnlineStore. Did you maybe mean updateRedirect()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        return $this->/** @scrutinizer ignore-call */ updateResource('redirects', $redirectId, $data);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
    }
48
49
    public function deleteRedirect($redirectId): void
50
    {
51
        $this->deleteResource('redirects', $redirectId);
0 ignored issues
show
Bug introduced by
The method deleteResource() does not exist on Signifly\Shopify\REST\Actions\ManagesOnlineStore. Did you maybe mean deleteRedirect()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $this->/** @scrutinizer ignore-call */ 
52
               deleteResource('redirects', $redirectId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
    }
53
54
    public function createBlog(array $data): BlogResource
55
    {
56
        return $this->createResource('blogs', $data);
57
    }
58
59
    public function getBlogsCount(array $params = []): int
60
    {
61
        return $this->getResourceCount('blogs', $params);
62
    }
63
64
    public function paginateBlogs(array $params = []): Cursor
65
    {
66
        return $this->cursor($this->getBlogs($params));
67
    }
68
69
    public function getBlogs(array $params = []): Collection
70
    {
71
        return $this->getResources('blogs', $params);
72
    }
73
74
    public function getBlog($blogId): BlogResource
75
    {
76
        return $this->getResource('blogs', $blogId);
77
    }
78
79
    public function updateBlog($blogId, $data): BlogResource
80
    {
81
        return $this->updateResource('blogs', $blogId, $data);
82
    }
83
84
    public function deleteBlog($blogId): void
85
    {
86
        $this->deleteResource('blogs', $blogId);
87
    }
88
89
    public function createPage(array $data): PageResource
90
    {
91
        return $this->createResource('pages', $data);
92
    }
93
94
    public function getPagesCount(array $params = []): int
95
    {
96
        return $this->getResourceCount('pages', $params);
97
    }
98
99
    public function paginatePages(array $params = []): Cursor
100
    {
101
        return $this->cursor($this->getPages($params));
102
    }
103
104
    public function getPages(array $params = []): Collection
105
    {
106
        return $this->getResources('pages', $params);
107
    }
108
109
    public function getPage($pageId): PageResource
110
    {
111
        return $this->getResource('pages', $pageId);
112
    }
113
114
    public function updatePage($pageId, $data): PageResource
115
    {
116
        return $this->updateResource('pages', $pageId, $data);
117
    }
118
119
    public function deletePage($pageId): void
120
    {
121
        $this->deleteResource('pages', $pageId);
122
    }
123
124
    public function createArticle(array $data): ArticleResource
125
    {
126
        return $this->createResource('articles', $data);
127
    }
128
129
    public function getArticlesCount(array $params = []): int
130
    {
131
        return $this->getResourceCount('articles', $params);
132
    }
133
134
    public function paginateArticles(array $params = []): Cursor
135
    {
136
        return $this->cursor($this->getArticles($params));
137
    }
138
139
    public function getArticles(array $params = []): Collection
140
    {
141
        return $this->getResources('articles', $params);
142
    }
143
144
    public function getArticleAuthors(): array
145
    {
146
        $response = $this->get('articles/authors.json');
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

146
        /** @scrutinizer ignore-call */ 
147
        $response = $this->get('articles/authors.json');
Loading history...
147
148
        return $response->json('authors');
149
    }
150
151
    public function getArticleTags(array $params = []): array
152
    {
153
        $response = $this->get('articles/tags.json', $params);
154
155
        return $response->json('tags');
156
    }
157
158
    public function getArticle($articleId): ArticleResource
159
    {
160
        return $this->getResource('articles', $articleId);
161
    }
162
163
    public function updateArticle($articleId, $data): ArticleResource
164
    {
165
        return $this->updateResource('articles', $articleId, $data);
166
    }
167
168
    public function deleteArticle($articleId): void
169
    {
170
        $this->deleteResource('articles', $articleId);
171
    }
172
}
173