@@ -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 | } |
@@ -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; |
@@ -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; |