Passed
Push — master ( f2f2ee...825ba1 )
by Morten Poul
04:51 queued 02:20
created

ManagesDiscounts::paginatePriceRules()   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
nc 1
nop 1
dl 0
loc 3
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\Resources\ApiResource;
7
use Signifly\Shopify\Shopify;
8
9
/** @mixin Shopify */
10
trait ManagesDiscounts
11
{
12
    public function createDiscountCode($priceRuleId, string $code): ApiResource
13
    {
14
        return $this->createResource('discount_codes', ['code' => $code], ['price_rules', $priceRuleId]);
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

14
        return $this->/** @scrutinizer ignore-call */ createResource('discount_codes', ['code' => $code], ['price_rules', $priceRuleId]);
Loading history...
15
    }
16
17
    public function getDiscountCodesCount(array $params = []): int
18
    {
19
        return $this->getResourceCount('discount_codes', $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

19
        return $this->/** @scrutinizer ignore-call */ getResourceCount('discount_codes', $params);
Loading history...
20
    }
21
22
    public function getDiscountCodes($priceRuleId, array $params = []): Collection
23
    {
24
        return $this->getResources('discount_codes', $params, ['price_rules', $priceRuleId]);
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

24
        return $this->/** @scrutinizer ignore-call */ getResources('discount_codes', $params, ['price_rules', $priceRuleId]);
Loading history...
25
    }
26
27
    public function getDiscountCode($priceRuleId, $discountCodeId): ApiResource
28
    {
29
        return $this->getResource('discount_codes', $discountCodeId, ['price_rules', $priceRuleId]);
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

29
        return $this->/** @scrutinizer ignore-call */ getResource('discount_codes', $discountCodeId, ['price_rules', $priceRuleId]);
Loading history...
30
    }
31
32
    public function updateDiscountCode($priceRuleId, $discountCodeId, string $code): ApiResource
33
    {
34
        return $this->updateResource('discount_codes', $discountCodeId, ['code' => $code], ['price_rules', $priceRuleId]);
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

34
        return $this->/** @scrutinizer ignore-call */ updateResource('discount_codes', $discountCodeId, ['code' => $code], ['price_rules', $priceRuleId]);
Loading history...
35
    }
36
37
    public function deleteDiscountCode($priceRuleId, $discountCodeId): void
38
    {
39
        $this->deleteResource('discount_codes', $discountCodeId, ['price_rules', $priceRuleId]);
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

39
        $this->/** @scrutinizer ignore-call */ 
40
               deleteResource('discount_codes', $discountCodeId, ['price_rules', $priceRuleId]);
Loading history...
40
    }
41
42
    public function createPriceRule(array $data): ApiResource
43
    {
44
        return $this->createResource('price_rules', $data);
45
    }
46
47
    public function getPriceRulesCount(array $params = []): int
48
    {
49
        return $this->getResourceCount('price_rules', $params);
50
    }
51
52
    public function paginatePriceRules(array $params = []): Cursor
0 ignored issues
show
Bug introduced by
The type Signifly\Shopify\REST\Actions\Cursor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
53
    {
54
        return $this->cursor($this->getPriceRules($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

54
        return $this->/** @scrutinizer ignore-call */ cursor($this->getPriceRules($params));
Loading history...
55
    }
56
57
    public function getPriceRules(array $params = []): Collection
58
    {
59
        return $this->getResources('price_rules', $params);
60
    }
61
62
    public function getPriceRule($priceRuleId): ApiResource
63
    {
64
        return $this->getResource('price_rules', $priceRuleId);
65
    }
66
67
    public function updatePriceRule($priceRuleId, $data): ApiResource
68
    {
69
        return $this->updateResource('price_rules', $priceRuleId, $data);
70
    }
71
72
    public function deletePriceRule($priceRuleId): void
73
    {
74
        $this->deleteResource('price_rules', $priceRuleId);
75
    }
76
}
77