@@ -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 | } |
@@ -87,11 +87,9 @@ discard block |
||
| 87 | 87 | protected function _removeWithPost (string $path, array $data, string $field = null, $diff = null) { |
| 88 | 88 | if ($this->hasGid()) { |
| 89 | 89 | return $this->_setWithPost($path, $data, $field); |
| 90 | - } |
|
| 91 | - elseif (is_array($diff)) { |
|
| 90 | + } elseif (is_array($diff)) { |
|
| 92 | 91 | $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
| 93 | - } |
|
| 94 | - elseif ($diff instanceof Closure) { |
|
| 92 | + } elseif ($diff instanceof Closure) { |
|
| 95 | 93 | $this->_set($field, array_filter($diff, $this->data[$field] ?? [])); |
| 96 | 94 | } |
| 97 | 95 | return $this; |
@@ -107,11 +105,9 @@ discard block |
||
| 107 | 105 | protected function _save (string $dir = null) { |
| 108 | 106 | if (isset($dir)) { |
| 109 | 107 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
| 110 | - } |
|
| 111 | - elseif ($this->isDiff()) { |
|
| 108 | + } elseif ($this->isDiff()) { |
|
| 112 | 109 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
| 113 | - } |
|
| 114 | - else { |
|
| 110 | + } else { |
|
| 115 | 111 | return $this; |
| 116 | 112 | } |
| 117 | 113 | /** @var array $remote */ |
@@ -162,8 +158,7 @@ discard block |
||
| 162 | 158 | if (isset($field)) { |
| 163 | 159 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$field] ?? $field])[$field] ?? null; |
| 164 | 160 | $this->_setMapped($field, $value); |
| 165 | - } |
|
| 166 | - else { |
|
| 161 | + } else { |
|
| 167 | 162 | $this->_setData($this->api->get($this, [], ['expand' => 'this'])); |
| 168 | 163 | } |
| 169 | 164 | $this->_cache(); |
@@ -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; |