@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param null|array $data |
83 | 83 | * @return null|static|mixed |
84 | 84 | */ |
85 | - protected static function toData ($caller, ?array $data) { |
|
85 | + protected static function toData($caller, ?array $data) { |
|
86 | 86 | return isset($data) ? new static($caller, $data) : null; |
87 | 87 | } |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param null|array $table |
94 | 94 | * @return DataSet |
95 | 95 | */ |
96 | - protected static function toDataSet ($caller, array $table = null) { |
|
96 | + protected static function toDataSet($caller, array $table = null) { |
|
97 | 97 | return new DataSet(static::toList($caller, $table)); |
98 | 98 | } |
99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param null|array[] $table |
105 | 105 | * @return Hash |
106 | 106 | */ |
107 | - protected static function toHash ($caller, array $table = null) { |
|
107 | + protected static function toHash($caller, array $table = null) { |
|
108 | 108 | unset($caller); |
109 | 109 | return new Hash($table ?? []); |
110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param null|array[] $table |
117 | 117 | * @return array|static[] |
118 | 118 | */ |
119 | - protected static function toList ($caller, array $table = null) { |
|
119 | + protected static function toList($caller, array $table = null) { |
|
120 | 120 | return array_map(function(array $row) use ($caller) { |
121 | 121 | return static::toData($caller, $row); |
122 | 122 | }, $table ?? []); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param Api|Data $caller |
127 | 127 | * @param array $data |
128 | 128 | */ |
129 | - public function __construct ($caller, array $data = []) { |
|
129 | + public function __construct($caller, array $data = []) { |
|
130 | 130 | if ($caller instanceof Api) { |
131 | 131 | $this->api = $caller; |
132 | 132 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @param array $args |
142 | 142 | * @return mixed |
143 | 143 | */ |
144 | - public function __call (string $method, array $args) { |
|
144 | + public function __call(string $method, array $args) { |
|
145 | 145 | static $cache = []; |
146 | - if (!$call =& $cache[$method]) { |
|
146 | + if (!$call = & $cache[$method]) { |
|
147 | 147 | preg_match('/^(filter|get|has|is|on|select|set|sort)(.+)$/', $method, $call); |
148 | 148 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
149 | 149 | return '_' . strtolower($match[0]); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param array $data |
157 | 157 | * @return $this |
158 | 158 | */ |
159 | - protected function apply (array $data) { |
|
159 | + protected function apply(array $data) { |
|
160 | 160 | $this->data = $data + $this->data; |
161 | 161 | $this->diff += array_fill_keys(array_keys($data), true); |
162 | 162 | return $this; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param string $key |
167 | 167 | * @return bool |
168 | 168 | */ |
169 | - final protected function exists (string $key): bool { |
|
169 | + final protected function exists(string $key): bool { |
|
170 | 170 | return array_key_exists($key, $this->data); |
171 | 171 | } |
172 | 172 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param callable $filter |
180 | 180 | * @return $this |
181 | 181 | */ |
182 | - protected function filter (string $key, callable $filter) { |
|
182 | + protected function filter(string $key, callable $filter) { |
|
183 | 183 | assert($this->data[$key] instanceof DataSet); |
184 | 184 | $this->data[$key]->filter($filter); |
185 | 185 | return $this; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param null $default |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - protected function get (string $key, $default = null) { |
|
198 | + protected function get(string $key, $default = null) { |
|
199 | 199 | $value = $this->data[$key] ?? $default; |
200 | 200 | return $value instanceof DataSet ? $value->getItems() : $value; |
201 | 201 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * @return array |
205 | 205 | */ |
206 | - public function getData (): array { |
|
206 | + public function getData(): array { |
|
207 | 207 | $data = array_map(function($value) { |
208 | 208 | if ($value instanceof AbstractData) { |
209 | 209 | return $value->getData(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * @return array |
219 | 219 | */ |
220 | - protected function getPatch (): array { |
|
220 | + protected function getPatch(): array { |
|
221 | 221 | $patch = []; |
222 | 222 | foreach ($this->data as $key => $value) { |
223 | 223 | // mapped structures |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param string $key |
248 | 248 | * @return bool |
249 | 249 | */ |
250 | - protected function has (string $key) { |
|
250 | + protected function has(string $key) { |
|
251 | 251 | $value = $this->data[$key] ?? null; |
252 | 252 | if (isset($value)) { |
253 | 253 | if (is_countable($value)) { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param array $data |
265 | 265 | * @return $this |
266 | 266 | */ |
267 | - protected function import (array $data) { |
|
267 | + protected function import(array $data) { |
|
268 | 268 | foreach ($this->map as $key => $callable) { |
269 | 269 | $data[$key] = call_user_func($callable, $this, $data[$key] ?? null); |
270 | 270 | } |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | * @param string $key |
285 | 285 | * @return bool |
286 | 286 | */ |
287 | - protected function is (string $key): bool { |
|
287 | + protected function is(string $key): bool { |
|
288 | 288 | return !empty($this->data[$key]); |
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | 292 | * @return bool |
293 | 293 | */ |
294 | - protected function isDiff (): bool { |
|
294 | + protected function isDiff(): bool { |
|
295 | 295 | if ($this->diff) { |
296 | 296 | return true; |
297 | 297 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param mixed ...$args |
318 | 318 | * @return $this |
319 | 319 | */ |
320 | - protected function notify (string $event, ...$args) { |
|
320 | + protected function notify(string $event, ...$args) { |
|
321 | 321 | $args[] = $this; |
322 | 322 | if (in_array($event, $this->_events)) { |
323 | 323 | throw new LogicException('Circular event: ' . implode(' -> ', $this->_events) . " -> **{$event}**"); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param Closure $observer |
346 | 346 | * @return $this |
347 | 347 | */ |
348 | - protected function on (string $event, Closure $observer) { |
|
348 | + protected function on(string $event, Closure $observer) { |
|
349 | 349 | $this->_observers[$event][] = $observer; |
350 | 350 | return $this; |
351 | 351 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param Closure $selector |
360 | 360 | * @return Data[] |
361 | 361 | */ |
362 | - protected function select (string $key, Closure $selector) { |
|
362 | + protected function select(string $key, Closure $selector) { |
|
363 | 363 | assert($this->data[$key] instanceof DataSet); |
364 | 364 | return $this->data[$key]->select($selector); |
365 | 365 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @param mixed $value |
374 | 374 | * @return $this |
375 | 375 | */ |
376 | - protected function set (string $key, $value) { |
|
376 | + protected function set(string $key, $value) { |
|
377 | 377 | $this->data[$key] = is_array($value) ? array_values($value) : $value; |
378 | 378 | $this->diff[$key] = true; |
379 | 379 | return $this; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param Closure $cmp |
389 | 389 | * @return $this |
390 | 390 | */ |
391 | - protected function sort (string $key, Closure $cmp) { |
|
391 | + protected function sort(string $key, Closure $cmp) { |
|
392 | 392 | $dataSet = $this->data[$key]; |
393 | 393 | assert($dataSet instanceof DataSet); |
394 | 394 | $dataSet->sort($cmp); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * Throws. |
17 | 17 | */ |
18 | - final public function delete (): void { |
|
18 | + final public function delete(): void { |
|
19 | 19 | throw new DomainException('This entity cannot be deleted.'); |
20 | 20 | } |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -71,31 +71,31 @@ discard block |
||
71 | 71 | 'addresses' => [Address::class, 'toDataSet'], |
72 | 72 | ]; |
73 | 73 | |
74 | - final protected static function getAdvancedSearchPath (): string { |
|
74 | + final protected static function getAdvancedSearchPath(): string { |
|
75 | 75 | return 'customers/search'; |
76 | 76 | } |
77 | 77 | |
78 | - final protected static function getMetafieldType (): string { |
|
78 | + final protected static function getMetafieldType(): string { |
|
79 | 79 | return 'customer'; |
80 | 80 | } |
81 | 81 | |
82 | - final protected static function getSearchPath (): string { |
|
82 | + final protected static function getSearchPath(): string { |
|
83 | 83 | return 'customers'; |
84 | 84 | } |
85 | 85 | |
86 | - final protected static function getSearchType (): string { |
|
86 | + final protected static function getSearchType(): string { |
|
87 | 87 | return 'customers'; |
88 | 88 | } |
89 | 89 | |
90 | - final protected static function getType (): string { |
|
90 | + final protected static function getType(): string { |
|
91 | 91 | return 'customer'; |
92 | 92 | } |
93 | 93 | |
94 | - final public function __toString (): string { |
|
94 | + final public function __toString(): string { |
|
95 | 95 | return "customers/{$this->getId()}"; |
96 | 96 | } |
97 | 97 | |
98 | - public function getActivationUrl (): string { |
|
98 | + public function getActivationUrl(): string { |
|
99 | 99 | assert($this->hasId()); |
100 | 100 | if (!$this->activationUrl) { |
101 | 101 | $remote = $this->api->post("{$this}/account_activation_url", []); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @return null|Address |
109 | 109 | */ |
110 | - public function getDefaultAddress () { |
|
110 | + public function getDefaultAddress() { |
|
111 | 111 | /** @var null|Address $address */ |
112 | 112 | $address = $this->data['addresses']->first(function(Address $address) { |
113 | 113 | return $address->isDefault(); |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | return $address; |
116 | 116 | } |
117 | 117 | |
118 | - final protected function getDir (): string { |
|
118 | + final protected function getDir(): string { |
|
119 | 119 | return 'customers'; |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @return Order[] |
124 | 124 | */ |
125 | - public function getOrders () { |
|
125 | + public function getOrders() { |
|
126 | 126 | assert($this->hasId()); |
127 | 127 | return Order::toList($this, $this->api->get("{$this}/orders")['orders']); |
128 | 128 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * @return Address |
132 | 132 | */ |
133 | - public function newAddress () { |
|
133 | + public function newAddress() { |
|
134 | 134 | return $this->data['addresses']->add(Address::toData($this, ['customer_id' => $this->getId()])); |
135 | 135 | } |
136 | 136 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return Invite |
141 | 141 | */ |
142 | - public function newInvite () { |
|
142 | + public function newInvite() { |
|
143 | 143 | return new Invite($this); |
144 | 144 | } |
145 | 145 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param Address $address |
150 | 150 | * @return $this |
151 | 151 | */ |
152 | - public function setDefaultAddress (Address $address) { |
|
152 | + public function setDefaultAddress(Address $address) { |
|
153 | 153 | assert($this->hasId()); |
154 | 154 | assert($address->hasId()); |
155 | 155 | assert($address->getCustomerId() === $this->getId()); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string $password |
166 | 166 | * @return $this |
167 | 167 | */ |
168 | - public function setPassword (string $password) { |
|
168 | + public function setPassword(string $password) { |
|
169 | 169 | return $this->apply([ |
170 | 170 | 'password' => $password, |
171 | 171 | 'password_confirmation' => $password |