Completed
Pull Request — master (#4)
by Morten Poul
11:21
created

ManagesStoreProperties::getShippingZones()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
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\CountryResource;
9
use Signifly\Shopify\Shopify;
10
11
/** @mixin Shopify */
12
trait ManagesStoreProperties
13
{
14
    public function createCountry(array $data): CountryResource
15
    {
16
        return $this->createResource('countries', $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

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

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

26
        return $this->/** @scrutinizer ignore-call */ getResources('countries', $params);
Loading history...
27
    }
28
29
    public function getCountry($countryId): CountryResource
30
    {
31
        return $this->getResource('countries', $countryId);
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

31
        return $this->/** @scrutinizer ignore-call */ getResource('countries', $countryId);
Loading history...
32
    }
33
34
    public function updateCountry($countryId, array $data): CountryResource
35
    {
36
        return $this->updateResource('countries', $countryId, $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

36
        return $this->/** @scrutinizer ignore-call */ updateResource('countries', $countryId, $data);
Loading history...
37
    }
38
39
    public function deleteCountry($countryId): void
40
    {
41
        $this->deleteResource('countries', $countryId);
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

41
        $this->/** @scrutinizer ignore-call */ 
42
               deleteResource('countries', $countryId);
Loading history...
42
    }
43
44
    public function paginateCurrencies(array $params = []): Cursor
45
    {
46
        return $this->cursor($this->getCurrencies($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

46
        return $this->/** @scrutinizer ignore-call */ cursor($this->getCurrencies($params));
Loading history...
47
    }
48
49
    public function getCurrencies(array $params = []): Collection
50
    {
51
        return $this->getResources('currencies', $params);
52
    }
53
54
    public function getPolicies(array $params = []): Collection
55
    {
56
        return $this->getResources('policies', $params);
57
    }
58
59
    public function getCountryProvincesCount($countryId, array $params = []): int
60
    {
61
        return $this->getResourceCount('provinces', $params, ['countries', $countryId]);
62
    }
63
64
    public function getCountryProvinces($countryId, array $params = []): Collection
65
    {
66
        return $this->getResources('provinces', $params, ['countries', $countryId]);
67
    }
68
69
    public function getCountryProvince($countryId, $provinceId): CountryResource
70
    {
71
        return $this->getResource('provinces', $provinceId, ['countries', $countryId]);
72
    }
73
74
    public function updateCountryProvince($countryId, $provinceId, array $data): CountryResource
75
    {
76
        return $this->updateResource('provinces', $provinceId, $data, ['countries', $countryId]);
77
    }
78
79
    public function getShippingZones(array $params = []): Collection
80
    {
81
        return $this->getResources('shipping_zones', $params);
82
    }
83
84
    public function shop(): ApiResource
85
    {
86
        $response = $this->get('shop.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

86
        /** @scrutinizer ignore-call */ 
87
        $response = $this->get('shop.json');
Loading history...
87
88
        return new ApiResource($response->json('shop'), $this);
89
    }
90
}
91