ProductResource::images()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Signifly\Shopify\REST\Resources;
4
5
use Illuminate\Support\Collection;
6
7
class ProductResource extends ApiResource
8
{
9
    public function update(array $data): self
10
    {
11
        return $this->shopify->updateProduct($this->id, $data);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
12
    }
13
14
    public function delete(): void
15
    {
16
        $this->shopify->deleteProduct($this->id);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
17
    }
18
19
    public function publish(): self
20
    {
21
        return $this->update(['published' => true]);
22
    }
23
24
    public function unpublish(): self
25
    {
26
        return $this->update(['published' => false]);
27
    }
28
29
    public function getImages(array $params = []): Collection
30
    {
31
        return $this->shopify->getProductImages($this->id, $params);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
    }
33
34
    public function getMetafields(array $params = []): Collection
35
    {
36
        return $this->shopify->getProductMetafields($this->id, $params);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
    }
38
39
    public function getVariants(array $params = []): Collection
40
    {
41
        return $this->shopify->getVariants($this->id, $params);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
    }
43
44
    public function images(): Collection
45
    {
46
        return Collection::make($this->images)
0 ignored issues
show
Bug Best Practice introduced by
The property images does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
47
            ->map(fn ($attributes) => new ImageResource($attributes, $this->shopify));
48
    }
49
50
    public function variants(): Collection
51
    {
52
        return Collection::make($this->variants)
0 ignored issues
show
Bug Best Practice introduced by
The property variants does not exist on Signifly\Shopify\REST\Resources\ProductResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
53
            ->map(fn ($attributes) => new VariantResource($attributes, $this->shopify));
54
    }
55
}
56