@@ -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 | } |
@@ -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 | } |
@@ -109,8 +109,7 @@ discard block |
||
| 109 | 109 | protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
| 110 | 110 | if ($this->hasGid()) { |
| 111 | 111 | return $this->_setWithPost($rmPath, $data, $field); |
| 112 | - } |
|
| 113 | - elseif (is_array($diff)) { |
|
| 112 | + } elseif (is_array($diff)) { |
|
| 114 | 113 | return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
| 115 | 114 | } |
| 116 | 115 | return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff))); |
@@ -126,11 +125,9 @@ discard block |
||
| 126 | 125 | protected function _save (string $dir = null) { |
| 127 | 126 | if (isset($dir)) { |
| 128 | 127 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
| 129 | - } |
|
| 130 | - elseif ($this->isDiff()) { |
|
| 128 | + } elseif ($this->isDiff()) { |
|
| 131 | 129 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
| 132 | - } |
|
| 133 | - else { |
|
| 130 | + } else { |
|
| 134 | 131 | return $this; |
| 135 | 132 | } |
| 136 | 133 | /** @var array $remote */ |
@@ -186,11 +183,9 @@ discard block |
||
| 186 | 183 | $optField = static::$optFields[$field] ?? $field; |
| 187 | 184 | $value = $this->api->get($this, [], ['fields' => $optField])[$field] ?? null; |
| 188 | 185 | $this->_setMapped($field, $value); |
| 189 | - } |
|
| 190 | - elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
| 186 | + } elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
| 191 | 187 | $this->_setData($remote); |
| 192 | - } |
|
| 193 | - else { // deleted upstream. |
|
| 188 | + } else { // deleted upstream. |
|
| 194 | 189 | $this->api->getCache()->remove($this); |
| 195 | 190 | throw new RuntimeException("{$this} was deleted upstream."); |
| 196 | 191 | } |
@@ -198,8 +198,7 @@ |
||
| 198 | 198 | $type = $this->data[$i]['type']; |
| 199 | 199 | if ($type === CustomField::TYPE_ENUM) { |
| 200 | 200 | $this->data[$i]['enum_value']['gid'] = $value; |
| 201 | - } |
|
| 202 | - else { |
|
| 201 | + } else { |
|
| 203 | 202 | $this->data["{$type}_value"] = $value; |
| 204 | 203 | } |
| 205 | 204 | $this->diff[$i] = true; |
@@ -315,8 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | if ($isList) { |
| 317 | 317 | $this->data[$field] = array_map($hydrate, $value); |
| 318 | - } |
|
| 319 | - else { |
|
| 318 | + } else { |
|
| 320 | 319 | $this->data[$field] = $hydrate($value); |
| 321 | 320 | } |
| 322 | 321 | } |
@@ -387,11 +386,9 @@ discard block |
||
| 387 | 386 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
| 388 | 387 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
| 389 | 388 | return $each->getGid(); |
| 390 | - } |
|
| 391 | - elseif ($each instanceof self) { |
|
| 389 | + } elseif ($each instanceof self) { |
|
| 392 | 390 | return $each->toArray(); |
| 393 | - } |
|
| 394 | - elseif (is_array($each)) { |
|
| 391 | + } elseif (is_array($each)) { |
|
| 395 | 392 | return array_map($dehydrate, $each); |
| 396 | 393 | } |
| 397 | 394 | return $each; |