Passed
Push — master ( b81bb3...35e0e4 )
by Morten Poul
11:42 queued 09:03
created

ManagesOnlineStore::updateAsset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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\AssetResource;
10
use Signifly\Shopify\REST\Resources\BlogResource;
11
use Signifly\Shopify\REST\Resources\PageResource;
12
use Signifly\Shopify\Shopify;
13
14
/** @mixin Shopify */
15
trait ManagesOnlineStore
16
{
17
    public function createRedirect(string $path, string $target): ApiResource
18
    {
19
        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

19
        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...
20
            'path' => $path,
21
            'target' => $target,
22
        ]);
23
    }
24
25
    public function getRedirectsCount(array $params = []): int
26
    {
27
        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

27
        return $this->/** @scrutinizer ignore-call */ getResourceCount('redirects', $params);
Loading history...
28
    }
29
30
    public function paginateRedirects(array $params = []): Cursor
31
    {
32
        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

32
        return $this->/** @scrutinizer ignore-call */ cursor($this->getRedirects($params));
Loading history...
33
    }
34
35
    public function getRedirects(array $params = []): Collection
36
    {
37
        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

37
        return $this->/** @scrutinizer ignore-call */ getResources('redirects', $params);
Loading history...
38
    }
39
40
    public function getRedirect($redirectId): ApiResource
41
    {
42
        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

42
        return $this->/** @scrutinizer ignore-call */ getResource('redirects', $redirectId);
Loading history...
43
    }
44
45
    public function updateRedirect($redirectId, $data): ApiResource
46
    {
47
        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

47
        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...
48
    }
49
50
    public function deleteRedirect($redirectId): void
51
    {
52
        $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

52
        $this->/** @scrutinizer ignore-call */ 
53
               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...
53
    }
54
55
    public function createBlog(array $data): BlogResource
56
    {
57
        return $this->createResource('blogs', $data);
58
    }
59
60
    public function getBlogsCount(array $params = []): int
61
    {
62
        return $this->getResourceCount('blogs', $params);
63
    }
64
65
    public function paginateBlogs(array $params = []): Cursor
66
    {
67
        return $this->cursor($this->getBlogs($params));
68
    }
69
70
    public function getBlogs(array $params = []): Collection
71
    {
72
        return $this->getResources('blogs', $params);
73
    }
74
75
    public function getBlog($blogId): BlogResource
76
    {
77
        return $this->getResource('blogs', $blogId);
78
    }
79
80
    public function updateBlog($blogId, $data): BlogResource
81
    {
82
        return $this->updateResource('blogs', $blogId, $data);
83
    }
84
85
    public function deleteBlog($blogId): void
86
    {
87
        $this->deleteResource('blogs', $blogId);
88
    }
89
90
    public function createPage(array $data): PageResource
91
    {
92
        return $this->createResource('pages', $data);
93
    }
94
95
    public function getPagesCount(array $params = []): int
96
    {
97
        return $this->getResourceCount('pages', $params);
98
    }
99
100
    public function paginatePages(array $params = []): Cursor
101
    {
102
        return $this->cursor($this->getPages($params));
103
    }
104
105
    public function getPages(array $params = []): Collection
106
    {
107
        return $this->getResources('pages', $params);
108
    }
109
110
    public function getPage($pageId): PageResource
111
    {
112
        return $this->getResource('pages', $pageId);
113
    }
114
115
    public function updatePage($pageId, $data): PageResource
116
    {
117
        return $this->updateResource('pages', $pageId, $data);
118
    }
119
120
    public function deletePage($pageId): void
121
    {
122
        $this->deleteResource('pages', $pageId);
123
    }
124
125
    public function createArticle(array $data): ArticleResource
126
    {
127
        return $this->createResource('articles', $data);
128
    }
129
130
    public function getArticlesCount(array $params = []): int
131
    {
132
        return $this->getResourceCount('articles', $params);
133
    }
134
135
    public function paginateArticles(array $params = []): Cursor
136
    {
137
        return $this->cursor($this->getArticles($params));
138
    }
139
140
    public function getArticles(array $params = []): Collection
141
    {
142
        return $this->getResources('articles', $params);
143
    }
144
145
    public function getArticleAuthors(): array
146
    {
147
        $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

147
        /** @scrutinizer ignore-call */ 
148
        $response = $this->get('articles/authors.json');
Loading history...
148
149
        return $response->json('authors');
150
    }
151
152
    public function getArticleTags(array $params = []): array
153
    {
154
        $response = $this->get('articles/tags.json', $params);
155
156
        return $response->json('tags');
157
    }
158
159
    public function getArticle($articleId): ArticleResource
160
    {
161
        return $this->getResource('articles', $articleId);
162
    }
163
164
    public function updateArticle($articleId, $data): ArticleResource
165
    {
166
        return $this->updateResource('articles', $articleId, $data);
167
    }
168
169
    public function deleteArticle($articleId): void
170
    {
171
        $this->deleteResource('articles', $articleId);
172
    }
173
174
    public function getAssets($themeId, array $params = []): Collection
175
    {
176
        return $this->getResources('assets', $params, ['themes', $themeId]);
177
    }
178
179
    public function getAsset($themeId, $assetKey): AssetResource
180
    {
181
        $response = $this->get('themes/' . $themeId . '/assets.json?asset[key]=' . $assetKey);
182
183
        return new AssetResource($response['asset'], $this);
184
    }
185
186
    public function updateAsset($themeId, array $data)
187
    {
188
        $response = $this->put('themes/' . $themeId . '/assets.json',  $data);
0 ignored issues
show
Bug introduced by
It seems like put() 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

188
        /** @scrutinizer ignore-call */ 
189
        $response = $this->put('themes/' . $themeId . '/assets.json',  $data);
Loading history...
189
190
        return new AssetResource($response['asset'], $this);
191
    }
192
193
    public function deleteAsset($themeId, $assetKey)
194
    {
195
        $this->delete('themes/' . $themeId . '/assets.json?asset[key]=' . $assetKey);
0 ignored issues
show
Bug introduced by
The method delete() does not exist on Signifly\Shopify\REST\Actions\ManagesOnlineStore. Did you maybe mean deleteBlog()? ( Ignorable by Annotation )

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

195
        $this->/** @scrutinizer ignore-call */ 
196
               delete('themes/' . $themeId . '/assets.json?asset[key]=' . $assetKey);

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...
196
    }
197
}
198