@@ -460,8 +460,7 @@ |
||
460 | 460 | 'sync' => $token, |
461 | 461 | 'opt_expand' => 'this' |
462 | 462 | ])); |
463 | - } |
|
464 | - catch (Error $error) { |
|
463 | + } catch (Error $error) { |
|
465 | 464 | if ($error->getCode() !== 412) { |
466 | 465 | throw $error; |
467 | 466 | } |
@@ -41,11 +41,9 @@ |
||
41 | 41 | if ($field['type'] === CustomField::TYPE_ENUM) { |
42 | 42 | $this->optionNames[$gid] = array_column($field['enum_options'], 'name', 'gid'); |
43 | 43 | $this->data[$gid] = $field['enum_value']['gid']; |
44 | - } |
|
45 | - elseif ($field['type'] === CustomField::TYPE_TEXT) { |
|
44 | + } elseif ($field['type'] === CustomField::TYPE_TEXT) { |
|
46 | 45 | $this->data[$gid] = $field['text_value']; |
47 | - } |
|
48 | - elseif ($field['type'] === CustomField::TYPE_NUMBER) { |
|
46 | + } elseif ($field['type'] === CustomField::TYPE_NUMBER) { |
|
49 | 47 | $this->data[$gid] = $field['number_value']; |
50 | 48 | } |
51 | 49 | } |
@@ -39,8 +39,7 @@ |
||
39 | 39 | try { |
40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
41 | 41 | return $colors[array_rand($colors)]; |
42 | - } |
|
43 | - catch (Exception $exception) { |
|
42 | + } catch (Exception $exception) { |
|
44 | 43 | return 'none'; // unreachable |
45 | 44 | } |
46 | 45 | } |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | if (is_array($class)) { |
219 | 219 | $class = $class[0]; |
220 | 220 | $this->data[$field] = array_map($hydrate, $value); |
221 | - } |
|
222 | - else { |
|
221 | + } else { |
|
223 | 222 | $this->data[$field] = $hydrate($value); |
224 | 223 | } |
225 | 224 | } |
@@ -324,11 +323,9 @@ discard block |
||
324 | 323 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
325 | 324 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
326 | 325 | return $each->getGid(); |
327 | - } |
|
328 | - elseif ($each instanceof self) { |
|
326 | + } elseif ($each instanceof self) { |
|
329 | 327 | return $each->toArray(); |
330 | - } |
|
331 | - elseif (is_array($each)) { |
|
328 | + } elseif (is_array($each)) { |
|
332 | 329 | return array_map($dehydrate, $each); |
333 | 330 | } |
334 | 331 | return $each; |
@@ -89,11 +89,9 @@ discard block |
||
89 | 89 | protected function _removeWithPost (string $path, array $data, string $field, $diff) { |
90 | 90 | if ($this->hasGid()) { |
91 | 91 | return $this->_setWithPost($path, $data, $field); |
92 | - } |
|
93 | - elseif (is_array($diff)) { |
|
92 | + } elseif (is_array($diff)) { |
|
94 | 93 | $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
95 | - } |
|
96 | - else { |
|
94 | + } else { |
|
97 | 95 | $this->_set($field, array_filter($this->data[$field] ?? [], $diff)); |
98 | 96 | } |
99 | 97 | return $this; |
@@ -109,11 +107,9 @@ discard block |
||
109 | 107 | protected function _save (string $dir = null) { |
110 | 108 | if (isset($dir)) { |
111 | 109 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
112 | - } |
|
113 | - elseif ($this->isDiff()) { |
|
110 | + } elseif ($this->isDiff()) { |
|
114 | 111 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
115 | - } |
|
116 | - else { |
|
112 | + } else { |
|
117 | 113 | return $this; |
118 | 114 | } |
119 | 115 | /** @var array $remote */ |
@@ -169,11 +165,9 @@ discard block |
||
169 | 165 | $optField = static::$optFields[$field] ?? $field; |
170 | 166 | $value = $this->api->get($this, [], ['fields' => $optField])[$field] ?? null; |
171 | 167 | $this->_setMapped($field, $value); |
172 | - } |
|
173 | - elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
168 | + } elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
174 | 169 | $this->_setData($remote); |
175 | - } |
|
176 | - else { // deleted upstream. |
|
170 | + } else { // deleted upstream. |
|
177 | 171 | $this->api->getCache()->remove($this); |
178 | 172 | throw new RuntimeException("{$this} was deleted upstream."); |
179 | 173 | } |