@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $key |
76 | 76 | * @param string $password |
77 | 77 | */ |
78 | - public function __construct (string $domain, string $key, string $password) { |
|
78 | + public function __construct(string $domain, string $key, string $password) { |
|
79 | 79 | $this->domain = $domain; |
80 | 80 | $this->key = $key; |
81 | 81 | $this->password = $password; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return null|mixed |
91 | 91 | * @internal |
92 | 92 | */ |
93 | - public function __call ($method, array $args) { |
|
93 | + public function __call($method, array $args) { |
|
94 | 94 | $ch = curl_init(); |
95 | 95 | $method = strtoupper($method); |
96 | 96 | if ($method[0] === 'P') { |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @return int |
160 | 160 | */ |
161 | - public function getBucket (): int { |
|
161 | + public function getBucket(): int { |
|
162 | 162 | return $this->bucket; |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | 166 | * @return int |
167 | 167 | */ |
168 | - public function getLastCallAt (): int { |
|
168 | + public function getLastCallAt(): int { |
|
169 | 169 | return $this->lastCallAt; |
170 | 170 | } |
171 | 171 | |
@@ -173,28 +173,28 @@ discard block |
||
173 | 173 | * @param string $id |
174 | 174 | * @return null|Location |
175 | 175 | */ |
176 | - public function getLocation (string $id) { |
|
176 | + public function getLocation(string $id) { |
|
177 | 177 | return $this->getLocations()[$id] ?? null; |
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @return Location[] |
182 | 182 | */ |
183 | - public function getLocations () { |
|
183 | + public function getLocations() { |
|
184 | 184 | return $this->locations ?? $this->locations = Location::loadAll($this); |
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @return Closure |
189 | 189 | */ |
190 | - public function getLogger (): Closure { |
|
190 | + public function getLogger(): Closure { |
|
191 | 191 | return $this->logger; |
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
195 | 195 | * @return Shop |
196 | 196 | */ |
197 | - public function getShop () { |
|
197 | + public function getShop() { |
|
198 | 198 | return $this->shop ?? $this->shop = Shop::load($this); |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param string|null $id |
205 | 205 | * @return null|User |
206 | 206 | */ |
207 | - public function getUser (string $id = null) { |
|
207 | + public function getUser(string $id = null) { |
|
208 | 208 | return $id ? User::load($this, $id) : User::me($this); |
209 | 209 | } |
210 | 210 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param Closure $logger |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - public function setLogger (Closure $logger) { |
|
215 | + public function setLogger(Closure $logger) { |
|
216 | 216 | $this->logger = $logger; |
217 | 217 | return $this; |
218 | 218 | } |
@@ -98,8 +98,7 @@ |
||
98 | 98 | $payload = json_encode($args[1], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
99 | 99 | curl_setopt($ch, CURLOPT_POST, true); |
100 | 100 | curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
101 | - } |
|
102 | - else { |
|
101 | + } else { |
|
103 | 102 | $query = $args[1] ?? []; |
104 | 103 | $payload = null; |
105 | 104 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | 'tax_lines' => [Tax::class, 'toList'] |
70 | 70 | ]; |
71 | 71 | |
72 | - final protected static function getSearchPath (): string { |
|
72 | + final protected static function getSearchPath(): string { |
|
73 | 73 | return 'checkouts'; |
74 | 74 | } |
75 | 75 | |
76 | - final protected static function getSearchType (): string { |
|
76 | + final protected static function getSearchType(): string { |
|
77 | 77 | return 'checkouts'; |
78 | 78 | } |
79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param array $table |
85 | 85 | * @return Discount[] |
86 | 86 | */ |
87 | - protected static function toDiscountList (AbandonedCheckout $caller, array $table = null) { |
|
87 | + protected static function toDiscountList(AbandonedCheckout $caller, array $table = null) { |
|
88 | 88 | return Discount::toList($caller, array_column($table ?? [], 'discount_code')); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -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 | } |