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