ManagesProducts   A
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 105
rs 10
c 1
b 0
f 0
wmc 21

21 Methods

Rating   Name   Duplication   Size   Complexity  
A getVariantsCount() 0 3 1
A getVariant() 0 3 1
A paginateVariants() 0 3 1
A updateVariant() 0 3 1
A getProducts() 0 3 1
A getProductImages() 0 3 1
A updateProductImage() 0 3 1
A deleteProductImage() 0 3 1
A deleteVariant() 0 3 1
A paginateProducts() 0 3 1
A createProductImage() 0 3 1
A getProductsCount() 0 3 1
A paginateProductImages() 0 3 1
A getProductImagesCount() 0 3 1
A getProductImage() 0 3 1
A getVariants() 0 3 1
A deleteProduct() 0 3 1
A createVariant() 0 3 1
A updateProduct() 0 3 1
A createProduct() 0 3 1
A getProduct() 0 3 1
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\ImageResource;
8
use Signifly\Shopify\REST\Resources\ProductResource;
9
use Signifly\Shopify\REST\Resources\VariantResource;
10
use Signifly\Shopify\Shopify;
11
12
/** @mixin Shopify */
13
trait ManagesProducts
14
{
15
    public function createProduct(array $data): ProductResource
16
    {
17
        return $this->createResource('products', $data);
0 ignored issues
show
Bug introduced by
It seems like createResource() 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

17
        return $this->/** @scrutinizer ignore-call */ createResource('products', $data);
Loading history...
18
    }
19
20
    public function getProductsCount(array $params = []): int
21
    {
22
        return $this->getResourceCount('products', $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

22
        return $this->/** @scrutinizer ignore-call */ getResourceCount('products', $params);
Loading history...
23
    }
24
25
    public function paginateProducts(array $params = []): Cursor
26
    {
27
        return $this->cursor($this->getProducts($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

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

32
        return $this->/** @scrutinizer ignore-call */ getResources('products', $params);
Loading history...
33
    }
34
35
    public function getProduct($productId): ProductResource
36
    {
37
        return $this->getResource('products', $productId);
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

37
        return $this->/** @scrutinizer ignore-call */ getResource('products', $productId);
Loading history...
38
    }
39
40
    public function updateProduct($productId, $data): ProductResource
41
    {
42
        return $this->updateResource('products', $productId, $data);
0 ignored issues
show
Bug introduced by
It seems like updateResource() 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 */ updateResource('products', $productId, $data);
Loading history...
43
    }
44
45
    public function deleteProduct($productId): void
46
    {
47
        $this->deleteResource('products', $productId);
0 ignored issues
show
Bug introduced by
It seems like deleteResource() 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

47
        $this->/** @scrutinizer ignore-call */ 
48
               deleteResource('products', $productId);
Loading history...
48
    }
49
50
    public function createVariant($productId, array $data): VariantResource
51
    {
52
        return $this->createResource('variants', $data, ['products', $productId]);
53
    }
54
55
    public function getVariantsCount($productId, array $params = []): int
56
    {
57
        return $this->getResourceCount('variants', $params, ['products', $productId]);
58
    }
59
60
    public function paginateVariants($productId, array $params = []): Cursor
61
    {
62
        return $this->cursor($this->getVariants($productId, $params));
63
    }
64
65
    public function getVariants($productId, array $params = []): Collection
66
    {
67
        return $this->getResources('variants', $params, ['products', $productId]);
68
    }
69
70
    public function getVariant($variantId): VariantResource
71
    {
72
        return $this->getResource('variants', $variantId);
73
    }
74
75
    public function updateVariant($variantId, array $data): VariantResource
76
    {
77
        return $this->updateResource('variants', $variantId, $data);
78
    }
79
80
    public function deleteVariant($productId, $variantId): void
81
    {
82
        $this->deleteResource('variants', $variantId, ['products', $productId]);
83
    }
84
85
    public function createProductImage($productId, array $data): ImageResource
86
    {
87
        return $this->createResource('images', $data, ['products', $productId]);
88
    }
89
90
    public function getProductImagesCount($productId, array $params = []): int
91
    {
92
        return $this->getResourceCount('images', $params, ['products', $productId]);
93
    }
94
95
    public function paginateProductImages($productId, array $params = []): Cursor
96
    {
97
        return $this->cursor($this->getProductImages($productId, $params));
98
    }
99
100
    public function getProductImages($productId, array $params = []): Collection
101
    {
102
        return $this->getResources('images', $params, ['products', $productId]);
103
    }
104
105
    public function getProductImage($productId, $imageId): ImageResource
106
    {
107
        return $this->getResource('images', $imageId, ['products', $productId]);
108
    }
109
110
    public function updateProductImage($productId, $imageId, array $data): ImageResource
111
    {
112
        return $this->updateResource('images', $imageId, $data, ['products', $productId]);
113
    }
114
115
    public function deleteProductImage($productId, $imageId): void
116
    {
117
        $this->deleteResource('images', $imageId, ['products', $productId]);
118
    }
119
}
120