@@ -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"; |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | 'receipt' => [Receipt::class, 'toData'] |
57 | 57 | ]; |
58 | 58 | |
59 | - final protected static function getType (): string { |
|
59 | + final protected static function getType(): string { |
|
60 | 60 | return 'fulfillment'; |
61 | 61 | } |
62 | 62 | |
63 | - final public function __toString (): string { |
|
63 | + final public function __toString(): string { |
|
64 | 64 | return "{$this->getDir()}/{$this->getId()}"; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function cancel () { |
|
70 | + public function cancel() { |
|
71 | 71 | assert($this->hasId()); |
72 | 72 | $remote = $this->api->post("{$this}/cancel", []); |
73 | 73 | return $this->import($remote['fulfillment'])->notify('save'); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * @return $this |
78 | 78 | */ |
79 | - public function complete () { |
|
79 | + public function complete() { |
|
80 | 80 | assert($this->hasId()); |
81 | 81 | $remote = $this->api->post("{$this}/complete", []); |
82 | 82 | return $this->import($remote['fulfillment'])->notify('save'); |
83 | 83 | } |
84 | 84 | |
85 | - final protected function getDir (): string { |
|
85 | + final protected function getDir(): string { |
|
86 | 86 | return "orders/{$this->getOrderId()}/fulfillments"; |
87 | 87 | } |
88 | 88 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | * @param string $orderItemId |
91 | 91 | * @return Item |
92 | 92 | */ |
93 | - public function newItem (string $orderItemId) { |
|
93 | + public function newItem(string $orderItemId) { |
|
94 | 94 | return $this->data['line_items']->add(Item::toData($this, ['id' => $orderItemId])); |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @return $this |
99 | 99 | */ |
100 | - public function open () { |
|
100 | + public function open() { |
|
101 | 101 | assert($this->hasId()); |
102 | 102 | $remote = $this->api->post("{$this}/open", []); |
103 | 103 | return $this->import($remote['fulfillment'])->notify('save'); |
@@ -46,36 +46,36 @@ discard block |
||
46 | 46 | 'transactions' => [Transaction::class, 'toDataSet'] |
47 | 47 | ]; |
48 | 48 | |
49 | - final protected static function getType (): string { |
|
49 | + final protected static function getType(): string { |
|
50 | 50 | return 'refund'; |
51 | 51 | } |
52 | 52 | |
53 | - final public function __toString (): string { |
|
53 | + final public function __toString(): string { |
|
54 | 54 | return "{$this->getDir()}/{$this->getId()}"; |
55 | 55 | } |
56 | 56 | |
57 | - final protected function getDir (): string { |
|
57 | + final protected function getDir(): string { |
|
58 | 58 | return "orders/{$this->getOrderId()}/refunds"; |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return RefundItem |
63 | 63 | */ |
64 | - public function newItem () { |
|
64 | + public function newItem() { |
|
65 | 65 | return $this->data['refund_line_items'][] = RefundItem::toData($this, []); |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return Transaction |
70 | 70 | */ |
71 | - public function newTransaction () { |
|
71 | + public function newTransaction() { |
|
72 | 72 | return $this->data['transactions'][] = Transaction::toData($this, ['kind' => Transaction::KIND_REFUND]); |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @return $this |
77 | 77 | */ |
78 | - public function setFullShipping () { |
|
78 | + public function setFullShipping() { |
|
79 | 79 | return $this->set('shipping', ['full_refund' => true]); |
80 | 80 | } |
81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string $amount |
84 | 84 | * @return $this |
85 | 85 | */ |
86 | - public function setShippingAmount (string $amount) { |
|
86 | + public function setShippingAmount(string $amount) { |
|
87 | 87 | return $this->set('shipping', ['amount' => $amount]); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | \ No newline at end of file |