@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | const SEARCH_STATUS_DISABLED = 'disabled'; |
45 | 45 | const SEARCH_STATUS_ENABLED = 'enabled'; |
46 | 46 | |
47 | - final protected static function getAdvancedSearchPath (): string { |
|
47 | + final protected static function getAdvancedSearchPath(): string { |
|
48 | 48 | return 'gift_cards/search'; |
49 | 49 | } |
50 | 50 | |
51 | - final protected static function getSearchPath (): string { |
|
51 | + final protected static function getSearchPath(): string { |
|
52 | 52 | return 'gift_cards'; |
53 | 53 | } |
54 | 54 | |
55 | - final protected static function getSearchType (): string { |
|
55 | + final protected static function getSearchType(): string { |
|
56 | 56 | return 'gift_cards'; |
57 | 57 | } |
58 | 58 | |
59 | - final protected static function getType (): string { |
|
59 | + final protected static function getType(): string { |
|
60 | 60 | return 'gift_card'; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $id |
66 | 66 | * @return null|static |
67 | 67 | */ |
68 | - public static function load (Api $api, string $id) { |
|
68 | + public static function load(Api $api, string $id) { |
|
69 | 69 | $proto = new static($api, ['id' => $id]); |
70 | 70 | if ($remote = $api->get($proto)) { |
71 | 71 | return $proto->import($remote['gift_card']); |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | return null; |
74 | 74 | } |
75 | 75 | |
76 | - final public function __toString (): string { |
|
76 | + final public function __toString(): string { |
|
77 | 77 | return "gift_cards/{$this->getId()}"; |
78 | 78 | } |
79 | 79 | |
80 | - final protected function getDir (): string { |
|
80 | + final protected function getDir(): string { |
|
81 | 81 | return 'gift_cards'; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -34,18 +34,18 @@ |
||
34 | 34 | |
35 | 35 | protected $patch = ['id']; |
36 | 36 | |
37 | - final protected static function getType (): string { |
|
37 | + final protected static function getType(): string { |
|
38 | 38 | return 'province'; |
39 | 39 | } |
40 | 40 | |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "countries/{$this->getCountryId()}/provinces/{$this->getId()}"; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return $this |
47 | 47 | */ |
48 | - public function save () { |
|
48 | + public function save() { |
|
49 | 49 | if ($this->isDiff()) { |
50 | 50 | $remote = $this->api->put($this, $this->getPatch()); |
51 | 51 | $this->import($remote['province']); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $id |
35 | 35 | * @return null|static |
36 | 36 | */ |
37 | - public static function load (Api $api, string $id) { |
|
37 | + public static function load(Api $api, string $id) { |
|
38 | 38 | if ($remote = $api->get("locations/{$id}")) { |
39 | 39 | return new static($api, $remote['location']); |
40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param Api $api |
46 | 46 | * @return static[] |
47 | 47 | */ |
48 | - public static function loadAll (Api $api) { |
|
48 | + public static function loadAll(Api $api) { |
|
49 | 49 | return static::toList(new static($api), $api->get('locations')['locations']); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | |
34 | 34 | protected $patch = ['key']; |
35 | 35 | |
36 | - final protected static function getType (): string { |
|
36 | + final protected static function getType(): string { |
|
37 | 37 | return 'asset'; |
38 | 38 | } |
39 | 39 | |
40 | - final public function __toString (): string { |
|
40 | + final public function __toString(): string { |
|
41 | 41 | return "{$this->getDir()}.json?asset[key]={$this->getKey()}"; |
42 | 42 | } |
43 | 43 | |
44 | - final protected function getDir (): string { |
|
44 | + final protected function getDir(): string { |
|
45 | 45 | return "themes/{$this->getThemeId()}/assets"; |
46 | 46 | } |
47 | 47 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return null|string |
54 | 54 | */ |
55 | - public function getValue () { |
|
55 | + public function getValue() { |
|
56 | 56 | if ($this->getCreatedAt() and !$this->exists('value')) { |
57 | 57 | $remote = $this->api->get("{$this}&fields=value"); |
58 | 58 | $this->data['value'] = $remote['asset']['value']; // bypass diff |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function save () { |
|
66 | + public function save() { |
|
67 | 67 | if ($this->isDiff()) { |
68 | 68 | $remote = $this->api->put($this->getDir(), $this->getPatch()); |
69 | 69 | // Preserve the value. |
@@ -43,7 +43,7 @@ |
||
43 | 43 | 'image' => [Image::class, 'toData'], |
44 | 44 | ]; |
45 | 45 | |
46 | - final protected static function getMetafieldType (): string { |
|
46 | + final protected static function getMetafieldType(): string { |
|
47 | 47 | return static::getType(); |
48 | 48 | } |
49 | 49 |
@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | use SearchTrait; |
26 | 26 | |
27 | - final protected static function getSearchPath (): string { |
|
27 | + final protected static function getSearchPath(): string { |
|
28 | 28 | return 'collects'; |
29 | 29 | } |
30 | 30 | |
31 | - final protected static function getSearchType (): string { |
|
31 | + final protected static function getSearchType(): string { |
|
32 | 32 | return 'collects'; |
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | */ |
22 | 22 | protected $collects; |
23 | 23 | |
24 | - final protected static function getSearchPath (): string { |
|
24 | + final protected static function getSearchPath(): string { |
|
25 | 25 | return 'custom_collections'; |
26 | 26 | } |
27 | 27 | |
28 | - final protected static function getSearchType (): string { |
|
28 | + final protected static function getSearchType(): string { |
|
29 | 29 | return 'custom_collections'; |
30 | 30 | } |
31 | 31 | |
32 | - final protected static function getType (): string { |
|
32 | + final protected static function getType(): string { |
|
33 | 33 | return 'custom_collection'; |
34 | 34 | } |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "custom_collections/{$this->getId()}"; |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param Product $product |
42 | 42 | * @return $this |
43 | 43 | */ |
44 | - public function addProduct (Product $product) { |
|
44 | + public function addProduct(Product $product) { |
|
45 | 45 | return $this->addProductById($product->getId()); |
46 | 46 | } |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $id |
50 | 50 | * @return $this |
51 | 51 | */ |
52 | - public function addProductById (string $id) { |
|
52 | + public function addProductById(string $id) { |
|
53 | 53 | $collect = $this->newCollect(); |
54 | 54 | $collect->setProductId($id); |
55 | 55 | if ($this->hasId()) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @return Collect[] |
63 | 63 | */ |
64 | - public function getCollects () { |
|
64 | + public function getCollects() { |
|
65 | 65 | if (!isset($this->collects)) { |
66 | 66 | if ($this->hasId()) { |
67 | 67 | $collects = Collect::search($this->api, ['collection_id' => $this->getId()]); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | return $this->collects->getItems(); |
75 | 75 | } |
76 | 76 | |
77 | - final protected function getDir (): string { |
|
77 | + final protected function getDir(): string { |
|
78 | 78 | return 'custom_collections'; |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - protected function getPatch (): array { |
|
86 | + protected function getPatch(): array { |
|
87 | 87 | $patch = parent::getPatch(); |
88 | 88 | if (!$this->hasId() and $this->collects) { |
89 | 89 | $patch['collects'] = $this->collects->getPatch(); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @return string[] |
96 | 96 | */ |
97 | - public function getProductIds () { |
|
97 | + public function getProductIds() { |
|
98 | 98 | return array_map(function(Collect $collect) { |
99 | 99 | return $collect->getProductId(); |
100 | 100 | }, $this->getCollects()); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @return Collect |
105 | 105 | */ |
106 | - protected function newCollect () { |
|
106 | + protected function newCollect() { |
|
107 | 107 | $collect = Collect::toData($this, ['collection_id' => $this->getId()]); |
108 | 108 | if (!$this->hasId() or isset($this->collects)) { |
109 | 109 | $this->getCollects(); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param Product $product |
119 | 119 | * @return $this |
120 | 120 | */ |
121 | - public function removeProduct (Product $product) { |
|
121 | + public function removeProduct(Product $product) { |
|
122 | 122 | return $this->removeProductById($product->getId()); |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $id |
129 | 129 | * @return $this |
130 | 130 | */ |
131 | - public function removeProductById (string $id) { |
|
131 | + public function removeProductById(string $id) { |
|
132 | 132 | foreach ($this->getCollects() as $collect) { |
133 | 133 | if ($collect->getProductId() === $id) { |
134 | 134 | $collect->delete(); |
@@ -66,8 +66,7 @@ |
||
66 | 66 | if ($this->hasId()) { |
67 | 67 | $collects = Collect::search($this->api, ['collection_id' => $this->getId()]); |
68 | 68 | $this->collects = new DataSet(iterator_to_array($collects)); |
69 | - } |
|
70 | - else { |
|
69 | + } else { |
|
71 | 70 | $this->collects = new DataSet(); |
72 | 71 | } |
73 | 72 | } |
@@ -31,19 +31,19 @@ |
||
31 | 31 | |
32 | 32 | use MetafieldTrait; |
33 | 33 | |
34 | - final protected static function getMetafieldType (): string { |
|
34 | + final protected static function getMetafieldType(): string { |
|
35 | 35 | return 'product_image'; |
36 | 36 | } |
37 | 37 | |
38 | - final protected static function getType (): string { |
|
38 | + final protected static function getType(): string { |
|
39 | 39 | return 'image'; |
40 | 40 | } |
41 | 41 | |
42 | - final public function __toString (): string { |
|
42 | + final public function __toString(): string { |
|
43 | 43 | return "{$this->getDir()}/{$this->getId()}"; |
44 | 44 | } |
45 | 45 | |
46 | - final protected function getDir (): string { |
|
46 | + final protected function getDir(): string { |
|
47 | 47 | return "products/{$this->getProductId()}/images"; |
48 | 48 | } |
49 | 49 |
@@ -62,19 +62,19 @@ |
||
62 | 62 | const POLICY_CONTINUE = 'continue'; |
63 | 63 | const POLICY_DENY = 'deny'; |
64 | 64 | |
65 | - final protected static function getMetafieldType (): string { |
|
65 | + final protected static function getMetafieldType(): string { |
|
66 | 66 | return 'product_variant'; |
67 | 67 | } |
68 | 68 | |
69 | - final protected static function getType (): string { |
|
69 | + final protected static function getType(): string { |
|
70 | 70 | return 'variant'; |
71 | 71 | } |
72 | 72 | |
73 | - final public function __toString (): string { |
|
73 | + final public function __toString(): string { |
|
74 | 74 | return "variants/{$this->getId()}"; |
75 | 75 | } |
76 | 76 | |
77 | - final protected function getDir (): string { |
|
77 | + final protected function getDir(): string { |
|
78 | 78 | return "products/{$this->getProductId()}/variants"; |
79 | 79 | } |
80 | 80 |