@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param null|array $data |
80 | 80 | * @return null|static|mixed |
81 | 81 | */ |
82 | - protected static function toData ($caller, ?array $data) { |
|
82 | + protected static function toData($caller, ?array $data) { |
|
83 | 83 | $object = isset($data) ? new static($caller, $data) : null; |
84 | 84 | return $object; |
85 | 85 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param null|array $table |
92 | 92 | * @return DataSet |
93 | 93 | */ |
94 | - protected static function toDataSet ($caller, array $table = null) { |
|
94 | + protected static function toDataSet($caller, array $table = null) { |
|
95 | 95 | return new DataSet(static::toList($caller, $table)); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param null|array[] $table |
103 | 103 | * @return Hash |
104 | 104 | */ |
105 | - protected static function toHash ($caller, array $table = null) { |
|
105 | + protected static function toHash($caller, array $table = null) { |
|
106 | 106 | unset($caller); |
107 | 107 | $hash = new Hash($table ?? []); |
108 | 108 | return $hash; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param null|array[] $table |
116 | 116 | * @return array|static[] |
117 | 117 | */ |
118 | - protected static function toList ($caller, array $table = null) { |
|
118 | + protected static function toList($caller, array $table = null) { |
|
119 | 119 | return array_map(function(array $row) use ($caller) { |
120 | 120 | return static::toData($caller, $row); |
121 | 121 | }, $table ?? []); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param Api|Data $caller |
126 | 126 | * @param array $data |
127 | 127 | */ |
128 | - public function __construct ($caller, array $data = []) { |
|
128 | + public function __construct($caller, array $data = []) { |
|
129 | 129 | if ($caller instanceof Api) { |
130 | 130 | $this->api = $caller; |
131 | 131 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * @param array $args |
141 | 141 | * @return mixed |
142 | 142 | */ |
143 | - public function __call (string $method, array $args) { |
|
143 | + public function __call(string $method, array $args) { |
|
144 | 144 | static $cache = []; |
145 | - if (!$call =& $cache[$method]) { |
|
145 | + if (!$call = & $cache[$method]) { |
|
146 | 146 | preg_match('/^(filter|get|has|is|on|select|set|sort)(.+)$/', $method, $call); |
147 | 147 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
148 | 148 | return '_' . strtolower($match[0]); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param array $data |
156 | 156 | * @return $this |
157 | 157 | */ |
158 | - protected function apply (array $data) { |
|
158 | + protected function apply(array $data) { |
|
159 | 159 | $this->data = $data + $this->data; |
160 | 160 | $this->diff += array_fill_keys(array_keys($data), true); |
161 | 161 | return $this; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string $key |
166 | 166 | * @return bool |
167 | 167 | */ |
168 | - final protected function exists (string $key): bool { |
|
168 | + final protected function exists(string $key): bool { |
|
169 | 169 | return array_key_exists($key, $this->data); |
170 | 170 | } |
171 | 171 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param callable $filter |
179 | 179 | * @return $this |
180 | 180 | */ |
181 | - protected function filter (string $key, callable $filter) { |
|
181 | + protected function filter(string $key, callable $filter) { |
|
182 | 182 | assert($this->data[$key] instanceof DataSet); |
183 | 183 | $this->data[$key]->filter($filter); |
184 | 184 | return $this; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param null $default |
195 | 195 | * @return mixed |
196 | 196 | */ |
197 | - protected function get (string $key, $default = null) { |
|
197 | + protected function get(string $key, $default = null) { |
|
198 | 198 | $value = $this->data[$key] ?? $default; |
199 | 199 | return $value instanceof DataSet ? $value->getItems() : $value; |
200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function getData (): array { |
|
205 | + public function getData(): array { |
|
206 | 206 | $data = array_map(function($value) { |
207 | 207 | if ($value instanceof AbstractData) { |
208 | 208 | return $value->getData(); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @return array |
218 | 218 | */ |
219 | - protected function getPatch (): array { |
|
219 | + protected function getPatch(): array { |
|
220 | 220 | $patch = []; |
221 | 221 | foreach ($this->data as $key => $value) { |
222 | 222 | // mapped structures |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param string $key |
247 | 247 | * @return bool |
248 | 248 | */ |
249 | - protected function has (string $key) { |
|
249 | + protected function has(string $key) { |
|
250 | 250 | $value = $this->data[$key] ?? null; |
251 | 251 | if (isset($value)) { |
252 | 252 | if (is_countable($value)) { |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param array $data |
264 | 264 | * @return $this |
265 | 265 | */ |
266 | - protected function import (array $data) { |
|
266 | + protected function import(array $data) { |
|
267 | 267 | foreach ($this->map as $key => $callable) { |
268 | 268 | $data[$key] = call_user_func($callable, $this, $data[$key] ?? null); |
269 | 269 | } |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | * @param string $key |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | - protected function is (string $key): bool { |
|
286 | + protected function is(string $key): bool { |
|
287 | 287 | return !empty($this->data[$key]); |
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | 291 | * @return bool |
292 | 292 | */ |
293 | - protected function isDiff (): bool { |
|
293 | + protected function isDiff(): bool { |
|
294 | 294 | if ($this->diff) { |
295 | 295 | return true; |
296 | 296 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param mixed ...$args |
317 | 317 | * @return $this |
318 | 318 | */ |
319 | - protected function notify (string $event, ...$args) { |
|
319 | + protected function notify(string $event, ...$args) { |
|
320 | 320 | $args[] = $this; |
321 | 321 | if (in_array($event, $this->_events)) { |
322 | 322 | throw new LogicException('Circular event: ' . implode(' -> ', $this->_events) . " -> **{$event}**"); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param Closure $observer |
345 | 345 | * @return $this |
346 | 346 | */ |
347 | - protected function on (string $event, Closure $observer) { |
|
347 | + protected function on(string $event, Closure $observer) { |
|
348 | 348 | $this->_observers[$event][] = $observer; |
349 | 349 | return $this; |
350 | 350 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param Closure $selector |
359 | 359 | * @return Data[] |
360 | 360 | */ |
361 | - protected function select (string $key, Closure $selector) { |
|
361 | + protected function select(string $key, Closure $selector) { |
|
362 | 362 | assert($this->data[$key] instanceof DataSet); |
363 | 363 | return $this->data[$key]->select($selector); |
364 | 364 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param mixed $value |
373 | 373 | * @return $this |
374 | 374 | */ |
375 | - protected function set (string $key, $value) { |
|
375 | + protected function set(string $key, $value) { |
|
376 | 376 | $this->data[$key] = is_array($value) ? array_values($value) : $value; |
377 | 377 | $this->diff[$key] = true; |
378 | 378 | return $this; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @param Closure $cmp |
388 | 388 | * @return $this |
389 | 389 | */ |
390 | - protected function sort (string $key, Closure $cmp) { |
|
390 | + protected function sort(string $key, Closure $cmp) { |
|
391 | 391 | $dataSet = $this->data[$key]; |
392 | 392 | assert($dataSet instanceof DataSet); |
393 | 393 | $dataSet->sort($cmp); |
@@ -128,8 +128,7 @@ |
||
128 | 128 | public function __construct ($caller, array $data = []) { |
129 | 129 | if ($caller instanceof Api) { |
130 | 130 | $this->api = $caller; |
131 | - } |
|
132 | - elseif ($caller instanceof Data) { |
|
131 | + } elseif ($caller instanceof Data) { |
|
133 | 132 | $this->api = $caller->api; |
134 | 133 | } |
135 | 134 | $this->import($data); |
@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | interface EntityInterface { |
14 | 14 | |
15 | - public function delete (): void; |
|
15 | + public function delete(): void; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @return $this |
19 | 19 | */ |
20 | - public function save (); |
|
20 | + public function save(); |
|
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -12,30 +12,30 @@ |
||
12 | 12 | /** |
13 | 13 | * @return array |
14 | 14 | */ |
15 | - abstract public function getData (): array; |
|
15 | + abstract public function getData(): array; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Returns a meaningful diff. |
19 | 19 | * |
20 | 20 | * @return array |
21 | 21 | */ |
22 | - abstract protected function getPatch (): array; |
|
22 | + abstract protected function getPatch(): array; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Whether there are changes. |
26 | 26 | * |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - abstract protected function isDiff (): bool; |
|
29 | + abstract protected function isDiff(): bool; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - final public function __debugInfo (): array { |
|
34 | + final public function __debugInfo(): array { |
|
35 | 35 | return $this->getData(); |
36 | 36 | } |
37 | 37 | |
38 | - final public function jsonSerialize () { |
|
38 | + final public function jsonSerialize() { |
|
39 | 39 | return $this->getData(); |
40 | 40 | } |
41 | 41 |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param array $table |
37 | 37 | */ |
38 | - public function __construct (array $table = []) { |
|
38 | + public function __construct(array $table = []) { |
|
39 | 39 | $this->data = array_column($table, $this->valueKey, $this->keyBy); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @return int |
44 | 44 | */ |
45 | - public function count () { |
|
45 | + public function count() { |
|
46 | 46 | return count($this->data); |
47 | 47 | } |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - public function getData (): array { |
|
54 | + public function getData(): array { |
|
55 | 55 | return array_map(function(string $key, $value) { |
56 | 56 | return [ |
57 | 57 | $this->keyBy => $key, |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @return Traversable|array |
65 | 65 | */ |
66 | - final public function getIterator () { |
|
66 | + final public function getIterator() { |
|
67 | 67 | yield from $this->data; |
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - protected function getPatch (): array { |
|
73 | + protected function getPatch(): array { |
|
74 | 74 | return $this->getData(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | - protected function isDiff (): bool { |
|
80 | + protected function isDiff(): bool { |
|
81 | 81 | return (bool)$this->diff; |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $key |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - public function offsetExists ($key) { |
|
88 | + public function offsetExists($key) { |
|
89 | 89 | return array_key_exists($key, $this->data); |
90 | 90 | } |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $key |
94 | 94 | * @return mixed |
95 | 95 | */ |
96 | - public function offsetGet ($key) { |
|
96 | + public function offsetGet($key) { |
|
97 | 97 | return $this->data[$key] ?? null; |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $key |
102 | 102 | * @param mixed $value |
103 | 103 | */ |
104 | - public function offsetSet ($key, $value) { |
|
104 | + public function offsetSet($key, $value) { |
|
105 | 105 | $this->data[$key] = $value; |
106 | 106 | $this->diff[$key] = true; |
107 | 107 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * @param string $key |
111 | 111 | */ |
112 | - public function offsetUnset ($key) { |
|
112 | + public function offsetUnset($key) { |
|
113 | 113 | unset($this->data[$key]); |
114 | 114 | $this->diff[$key] = true; |
115 | 115 | } |
@@ -13,21 +13,21 @@ |
||
13 | 13 | * @param array $args |
14 | 14 | * @return string |
15 | 15 | */ |
16 | - abstract protected static function getAdvancedSearchPath (array $args): string; |
|
16 | + abstract protected static function getAdvancedSearchPath(array $args): string; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * The pluralized key that results are wrapped in. |
20 | 20 | * |
21 | 21 | * @return string |
22 | 22 | */ |
23 | - abstract protected static function getSearchType (): string; |
|
23 | + abstract protected static function getSearchType(): string; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param Api $api |
27 | 27 | * @param array $args |
28 | 28 | * @return Traversable|static[] |
29 | 29 | */ |
30 | - public static function advancedSearch (Api $api, array $args) { |
|
30 | + public static function advancedSearch(Api $api, array $args) { |
|
31 | 31 | $continue = !isset($args['limit']); |
32 | 32 | $args['limit'] += ['limit' => 250]; |
33 | 33 | $path = static::getAdvancedSearchPath($args); |
@@ -32,12 +32,12 @@ |
||
32 | 32 | |
33 | 33 | protected $curlInfo = []; |
34 | 34 | |
35 | - public function __construct (int $code, string $message, array $curlInfo) { |
|
35 | + public function __construct(int $code, string $message, array $curlInfo) { |
|
36 | 36 | parent::__construct(self::NO_DATA[$code] ?? $message, $code); |
37 | 37 | $this->curlInfo = $curlInfo; |
38 | 38 | } |
39 | 39 | |
40 | - public function getCurlInfo (): array { |
|
40 | + public function getCurlInfo(): array { |
|
41 | 41 | return $this->curlInfo; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | class CountrySystemCode extends Data { |
14 | 14 | |
15 | - final public function __toString (): string { |
|
15 | + final public function __toString(): string { |
|
16 | 16 | return $this->getHarmonizedSystemCode(); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -29,27 +29,27 @@ |
||
29 | 29 | use MetafieldTrait; |
30 | 30 | use SearchTrait; |
31 | 31 | |
32 | - final protected static function getMetafieldType (): string { |
|
32 | + final protected static function getMetafieldType(): string { |
|
33 | 33 | return 'page'; |
34 | 34 | } |
35 | 35 | |
36 | - final protected static function getSearchPath (): string { |
|
36 | + final protected static function getSearchPath(): string { |
|
37 | 37 | return 'pages'; |
38 | 38 | } |
39 | 39 | |
40 | - final protected static function getSearchType (): string { |
|
40 | + final protected static function getSearchType(): string { |
|
41 | 41 | return 'pages'; |
42 | 42 | } |
43 | 43 | |
44 | - final protected static function getType (): string { |
|
44 | + final protected static function getType(): string { |
|
45 | 45 | return 'page'; |
46 | 46 | } |
47 | 47 | |
48 | - final public function __toString (): string { |
|
48 | + final public function __toString(): string { |
|
49 | 49 | return "pages/{$this->getId()}"; |
50 | 50 | } |
51 | 51 | |
52 | - final protected function getDir (): string { |
|
52 | + final protected function getDir(): string { |
|
53 | 53 | return 'pages'; |
54 | 54 | } |
55 | 55 |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected $owner; |
45 | 45 | |
46 | - final protected static function getType (): string { |
|
46 | + final protected static function getType(): string { |
|
47 | 47 | return 'metafield'; |
48 | 48 | } |
49 | 49 | |
50 | - public function __construct (Data $owner, array $data) { |
|
50 | + public function __construct(Data $owner, array $data) { |
|
51 | 51 | $this->owner = $owner; |
52 | 52 | parent::__construct($owner, $data); |
53 | 53 | } |
54 | 54 | |
55 | - final public function __toString (): string { |
|
55 | + final public function __toString(): string { |
|
56 | 56 | return "{$this->dir}/{$this->getId()}"; |
57 | 57 | } |
58 | 58 | |
59 | - protected function getDir (): string { |
|
59 | + protected function getDir(): string { |
|
60 | 60 | if ($this->owner instanceof Shop) { |
61 | 61 | return 'metafields'; |
62 | 62 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param mixed $value |
74 | 74 | * @return $this |
75 | 75 | */ |
76 | - public function setValue ($value) { |
|
76 | + public function setValue($value) { |
|
77 | 77 | if (is_int($value)) { |
78 | 78 | $this->set('value_type', self::TYPE_INT); |
79 | 79 | return $this->set('value', $value); |
@@ -59,11 +59,9 @@ |
||
59 | 59 | protected function getDir (): string { |
60 | 60 | if ($this->owner instanceof Shop) { |
61 | 61 | return 'metafields'; |
62 | - } |
|
63 | - elseif ($this->owner instanceof AbstractCollection) { |
|
62 | + } elseif ($this->owner instanceof AbstractCollection) { |
|
64 | 63 | return "collections/{$this->owner->getId()}/metafields"; |
65 | - } |
|
66 | - elseif ($this->owner instanceof Variant) { |
|
64 | + } elseif ($this->owner instanceof Variant) { |
|
67 | 65 | return "{$this->owner->getDir()}/{$this->owner->getId()}/metafields"; |
68 | 66 | } |
69 | 67 | return "{$this->owner}/metafields"; |