@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * `DELETE` |
12 | 12 | */ |
13 | - public function delete (): void { |
|
13 | + public function delete(): void { |
|
14 | 14 | $this->{'_delete'}(); |
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return $this |
14 | 14 | */ |
15 | - public function update () { |
|
15 | + public function update() { |
|
16 | 16 | return $this->{'_save'}(); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -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; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param Api|Data $caller |
49 | 49 | * @param array $data |
50 | 50 | */ |
51 | - public function __construct ($caller, array $data = []) { |
|
51 | + public function __construct($caller, array $data = []) { |
|
52 | 52 | $this->api = $caller instanceof self ? $caller->api : $caller; |
53 | 53 | $this->_setData($data); |
54 | 54 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param array $args |
65 | 65 | * @return mixed |
66 | 66 | */ |
67 | - public function __call (string $method, array $args) { |
|
67 | + public function __call(string $method, array $args) { |
|
68 | 68 | static $cache = []; |
69 | - if (!$call =& $cache[$method]) { |
|
69 | + if (!$call = & $cache[$method]) { |
|
70 | 70 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
71 | 71 | $call[1] = '_' . $call[1]; |
72 | 72 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return $this->{$call[1]}($call[2], ...$args); |
77 | 77 | } |
78 | 78 | |
79 | - public function __debugInfo (): array { |
|
79 | + public function __debugInfo(): array { |
|
80 | 80 | return $this->data; |
81 | 81 | } |
82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param $field |
87 | 87 | * @return null|Data|mixed |
88 | 88 | */ |
89 | - final public function __get ($field) { |
|
89 | + final public function __get($field) { |
|
90 | 90 | return $this->_get($field); |
91 | 91 | } |
92 | 92 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param $field |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - final public function __isset ($field) { |
|
101 | + final public function __isset($field) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $data |
110 | 110 | * @return mixed|Data|AbstractEntity |
111 | 111 | */ |
112 | - final protected function _factory (string $class, array $data = []) { |
|
112 | + final protected function _factory(string $class, array $data = []) { |
|
113 | 113 | return $this->api->factory($class, $this, $data); |
114 | 114 | } |
115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param string $field |
122 | 122 | * @return mixed |
123 | 123 | */ |
124 | - protected function _get (string $field) { |
|
124 | + protected function _get(string $field) { |
|
125 | 125 | return $this->data[$field] ?? null; |
126 | 126 | } |
127 | 127 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $field |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - protected function _has (string $field): bool { |
|
139 | + protected function _has(string $field): bool { |
|
140 | 140 | $value = $this->_get($field); |
141 | 141 | if (isset($value)) { |
142 | 142 | if (is_countable($value)) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field |
160 | 160 | * @return bool |
161 | 161 | */ |
162 | - protected function _is (string $field): bool { |
|
162 | + protected function _is(string $field): bool { |
|
163 | 163 | return (bool)$this->_get($field); |
164 | 164 | } |
165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $query |
174 | 174 | * @return null|mixed|AbstractEntity |
175 | 175 | */ |
176 | - final protected function _load (string $class, string $path, array $query = []) { |
|
176 | + final protected function _load(string $class, string $path, array $query = []) { |
|
177 | 177 | return $this->api->load($class, $this, $path, $query); |
178 | 178 | } |
179 | 179 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param int $pages |
189 | 189 | * @return array|AbstractEntity[] |
190 | 190 | */ |
191 | - final protected function _loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
191 | + final protected function _loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
192 | 192 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
193 | 193 | } |
194 | 194 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param int $pages |
204 | 204 | * @return Traversable|AbstractEntity[] |
205 | 205 | */ |
206 | - final protected function _loadEach (string $class, string $path, array $query = [], int $pages = 0) { |
|
206 | + final protected function _loadEach(string $class, string $path, array $query = [], int $pages = 0) { |
|
207 | 207 | return $this->api->loadEach($class, $this, $path, $query, $pages); |
208 | 208 | } |
209 | 209 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param callable $filter `fn( Data $object ): bool` |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected function _select ($subject, callable $filter) { |
|
221 | + protected function _select($subject, callable $filter) { |
|
222 | 222 | if (!is_iterable($subject)) { |
223 | 223 | $subject = $this->_get($subject) ?? []; |
224 | 224 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param mixed $value |
241 | 241 | * @return $this |
242 | 242 | */ |
243 | - protected function _set (string $field, $value) { |
|
243 | + protected function _set(string $field, $value) { |
|
244 | 244 | $this->data[$field] = $value; |
245 | 245 | $this->diff[$field] = true; |
246 | 246 | return $this; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param array $data |
253 | 253 | */ |
254 | - protected function _setData (array $data): void { |
|
254 | + protected function _setData(array $data): void { |
|
255 | 255 | $this->data = $this->diff = []; |
256 | 256 | foreach ($data as $field => $value) { |
257 | 257 | $this->_setMapped($field, $value); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $field |
265 | 265 | * @param mixed $value |
266 | 266 | */ |
267 | - protected function _setMapped (string $field, $value): void { |
|
267 | + protected function _setMapped(string $field, $value): void { |
|
268 | 268 | unset($this->diff[$field]); |
269 | 269 | |
270 | 270 | // use value as-is? |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return array |
312 | 312 | */ |
313 | - public function getDiff (): array { |
|
313 | + public function getDiff(): array { |
|
314 | 314 | $convert = function($each) use (&$convert) { |
315 | 315 | // convert existing entities to gids |
316 | 316 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param string null $field |
337 | 337 | * @return bool |
338 | 338 | */ |
339 | - final public function isDiff (string $field = null): bool { |
|
339 | + final public function isDiff(string $field = null): bool { |
|
340 | 340 | if ($field) { |
341 | 341 | return isset($this->diff[$field]); |
342 | 342 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @see toArray() |
348 | 348 | * @return array |
349 | 349 | */ |
350 | - public function jsonSerialize (): array { |
|
350 | + public function jsonSerialize(): array { |
|
351 | 351 | $data = $this->toArray(); |
352 | 352 | ksort($data); |
353 | 353 | return $data; |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function serialize (): string { |
|
362 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
361 | + public function serialize(): string { |
|
362 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public function toArray (): array { |
|
370 | + public function toArray(): array { |
|
371 | 371 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
372 | 372 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
373 | 373 | return $each->getGid(); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @param $serialized |
389 | 389 | */ |
390 | - public function unserialize ($serialized): void { |
|
390 | + public function unserialize($serialized): void { |
|
391 | 391 | $this->api = Api::getDefault(); |
392 | 392 | $data = json_decode($serialized, true); |
393 | 393 | $this->_setData($data); |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected $customField; |
35 | 35 | |
36 | - public function __construct (CustomField $customField, array $data = []) { |
|
36 | + public function __construct(CustomField $customField, array $data = []) { |
|
37 | 37 | parent::__construct($customField, $data); |
38 | 38 | $this->customField = $customField; |
39 | 39 | } |
40 | 40 | |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "enum_options/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
45 | - final protected function _getDir (): string { |
|
45 | + final protected function _getDir(): string { |
|
46 | 46 | return "{$this->customField}/enum_options"; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return CustomField |
51 | 51 | */ |
52 | - public function getCustomField () { |
|
52 | + public function getCustomField() { |
|
53 | 53 | return $this->customField; |
54 | 54 | } |
55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param EnumOption $option |
59 | 59 | * @return $this |
60 | 60 | */ |
61 | - public function moveAfter (EnumOption $option) { |
|
61 | + public function moveAfter(EnumOption $option) { |
|
62 | 62 | $this->api->post("{$this->_getDir()}/insert", [ |
63 | 63 | 'after_enum_option' => $option->getGid(), |
64 | 64 | 'enum_option' => $this->getGid() |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param EnumOption $option |
73 | 73 | * @return $this |
74 | 74 | */ |
75 | - public function moveBefore (EnumOption $option) { |
|
75 | + public function moveBefore(EnumOption $option) { |
|
76 | 76 | $this->api->post("{$this->_getDir()}/insert", [ |
77 | 77 | 'before_enum_option' => $option->getGid(), |
78 | 78 | 'enum_option' => $this->getGid() |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * @return $this |
86 | 86 | */ |
87 | - public function moveFirst () { |
|
87 | + public function moveFirst() { |
|
88 | 88 | $first = $this->customField->getEnumOptions()[0]; |
89 | 89 | if ($first !== $this) { |
90 | 90 | $this->moveBefore($first); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function moveLast () { |
|
98 | + public function moveLast() { |
|
99 | 99 | $options = $this->customField->getEnumOptions(); |
100 | 100 | $last = $options[count($options) - 1]; |
101 | 101 | if ($last !== $this) { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @param Workspace $workspace |
18 | 18 | * @return $this |
19 | 19 | */ |
20 | - public function setWorkspace (Workspace $workspace) { |
|
20 | + public function setWorkspace(Workspace $workspace) { |
|
21 | 21 | return $this->{'_set'}('workspace', $workspace); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $task; |
26 | 26 | |
27 | - public function __construct (Task $task, array $data = []) { |
|
27 | + public function __construct(Task $task, array $data = []) { |
|
28 | 28 | parent::__construct($task, $data); |
29 | 29 | $this->task = $task; |
30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param mixed $value |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - protected function _set (string $field, $value) { |
|
39 | + protected function _set(string $field, $value) { |
|
40 | 40 | $this->task->diff['external'] = true; |
41 | 41 | return parent::_set($field, $value); |
42 | 42 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return null|bool|number|string|array |
48 | 48 | */ |
49 | - public function getDataJsonDecoded () { |
|
49 | + public function getDataJsonDecoded() { |
|
50 | 50 | if (strlen($data = $this->getData())) { |
51 | - return json_decode($data, true, 512, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
51 | + return json_decode($data, true, 512, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
52 | 52 | } |
53 | 53 | return null; |
54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param mixed $data |
61 | 61 | * @return $this |
62 | 62 | */ |
63 | - public function setDataJsonEncoded ($data) { |
|
63 | + public function setDataJsonEncoded($data) { |
|
64 | 64 | if (isset($data)) { |
65 | 65 | return $this->setData(json_encode($data, JSON_THROW_ON_ERROR)); |
66 | 66 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @param PSR16 $psr |
36 | 36 | */ |
37 | - public function __construct (PSR16 $psr) { |
|
37 | + public function __construct(PSR16 $psr) { |
|
38 | 38 | $this->psr = $psr; |
39 | 39 | $this->ttl = new DateInterval('PT1H'); |
40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $key |
44 | 44 | * @throws InvalidArgumentException |
45 | 45 | */ |
46 | - protected function _delete (string $key) { |
|
46 | + protected function _delete(string $key) { |
|
47 | 47 | $this->psr->delete('asana/' . $key); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return null|string|AbstractEntity |
53 | 53 | * @throws InvalidArgumentException |
54 | 54 | */ |
55 | - protected function _get (string $key) { |
|
55 | + protected function _get(string $key) { |
|
56 | 56 | return $this->psr->get('asana/' . $key); |
57 | 57 | } |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param mixed $value |
62 | 62 | * @throws InvalidArgumentException |
63 | 63 | */ |
64 | - protected function _set (string $key, $value) { |
|
64 | + protected function _set(string $key, $value) { |
|
65 | 65 | $this->psr->set('asana/' . $key, $value, $this->ttl); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | * @throws InvalidArgumentException |
72 | 72 | */ |
73 | - public function add (AbstractEntity $entity): bool { |
|
73 | + public function add(AbstractEntity $entity): bool { |
|
74 | 74 | if (parent::add($entity)) { |
75 | 75 | $this->_set($entity->getGid(), $entity); |
76 | 76 | return true; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string[] $keys |
84 | 84 | * @throws InvalidArgumentException |
85 | 85 | */ |
86 | - protected function addKeys (string $gid, array $keys): void { |
|
86 | + protected function addKeys(string $gid, array $keys): void { |
|
87 | 87 | parent::addKeys($gid, $keys); |
88 | 88 | // stash gid refs |
89 | 89 | foreach ($keys as $key) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return null|AbstractEntity |
101 | 101 | * @throws InvalidArgumentException |
102 | 102 | */ |
103 | - public function get (string $key, $caller, Closure $factory) { |
|
103 | + public function get(string $key, $caller, Closure $factory) { |
|
104 | 104 | // POOL MISS && CACHE HIT |
105 | 105 | if (!isset($this->gids[$key]) and $entity = $this->_get($key)) { |
106 | 106 | if ($entity instanceof AbstractEntity) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * @return DateInterval |
125 | 125 | */ |
126 | - public function getTtl () { |
|
126 | + public function getTtl() { |
|
127 | 127 | return $this->ttl; |
128 | 128 | } |
129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param AbstractEntity $entity |
132 | 132 | * @throws InvalidArgumentException |
133 | 133 | */ |
134 | - public function remove (AbstractEntity $entity): void { |
|
134 | + public function remove(AbstractEntity $entity): void { |
|
135 | 135 | parent::remove($entity); |
136 | 136 | foreach ($entity->getCacheKeys() as $key) { |
137 | 137 | $this->_delete($key); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param DateInterval $ttl |
143 | 143 | * @return $this |
144 | 144 | */ |
145 | - public function setTtl (DateInterval $ttl) { |
|
145 | + public function setTtl(DateInterval $ttl) { |
|
146 | 146 | $this->ttl = $ttl; |
147 | 147 | return $this; |
148 | 148 | } |
@@ -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 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return string |
24 | 24 | */ |
25 | - abstract public function __toString (): string; |
|
25 | + abstract public function __toString(): string; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param AbstractEntity $entity |
43 | 43 | * @internal |
44 | 44 | */ |
45 | - public function __set (string $from, self $entity) { |
|
45 | + public function __set(string $from, self $entity) { |
|
46 | 46 | if ($from === Cache::class and $entity !== $this) { |
47 | 47 | foreach ($entity->data as $field => $value) { |
48 | 48 | if (!isset($this->diff[$field])) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return $this |
61 | 61 | * @internal |
62 | 62 | */ |
63 | - protected function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
63 | + protected function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
64 | 64 | if ($this->hasGid()) { |
65 | 65 | return $this->_setWithPost($addPath, $data, $field); |
66 | 66 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @internal |
74 | 74 | */ |
75 | - protected function _cache (): void { |
|
75 | + protected function _cache(): void { |
|
76 | 76 | $this->api->getCache()->add($this); |
77 | 77 | } |
78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @internal |
83 | 83 | */ |
84 | - protected function _delete (): void { |
|
84 | + protected function _delete(): void { |
|
85 | 85 | $this->api->delete($this); |
86 | 86 | $this->api->getCache()->remove($this); |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string $field |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - protected function _get (string $field) { |
|
95 | + protected function _get(string $field) { |
|
96 | 96 | if (!array_key_exists($field, $this->data) and $this->hasGid()) { |
97 | 97 | $this->reload($field); |
98 | 98 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return $this |
108 | 108 | * @internal |
109 | 109 | */ |
110 | - protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
110 | + protected function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
111 | 111 | if ($this->hasGid()) { |
112 | 112 | return $this->_setWithPost($rmPath, $data, $field); |
113 | 113 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return $this |
125 | 125 | * @internal |
126 | 126 | */ |
127 | - protected function _save (string $dir = null) { |
|
127 | + protected function _save(string $dir = null) { |
|
128 | 128 | if (isset($dir)) { |
129 | 129 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
130 | 130 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - protected function _setData (array $data): void { |
|
143 | + protected function _setData(array $data): void { |
|
144 | 144 | // make sure gid is consistently null|string across all entities. |
145 | 145 | $data['gid'] = empty($data['gid']) ? null : (string)$data['gid']; |
146 | 146 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return $this |
161 | 161 | * @internal |
162 | 162 | */ |
163 | - protected function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
163 | + protected function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
164 | 164 | if ($this->hasGid()) { |
165 | 165 | /** @var array $remote */ |
166 | 166 | $remote = $this->api->post($path, $data, ['fields' => static::$optFields[$field] ?? $field]); |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return string[] |
180 | 180 | */ |
181 | - public function getCacheKeys () { |
|
181 | + public function getCacheKeys() { |
|
182 | 182 | return [$this->getGid(), (string)$this]; |
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @return null|string |
187 | 187 | */ |
188 | - final public function getGid (): ?string { |
|
188 | + final public function getGid(): ?string { |
|
189 | 189 | return $this->data['gid']; |
190 | 190 | } |
191 | 191 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - final public function getResourceType (): string { |
|
197 | + final public function getResourceType(): string { |
|
198 | 198 | return $this::TYPE; |
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - final public function hasGid (): bool { |
|
204 | + final public function hasGid(): bool { |
|
205 | 205 | return isset($this->data['gid']); |
206 | 206 | } |
207 | 207 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param string $field |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - public function reload (string $field = null) { |
|
215 | + public function reload(string $field = null) { |
|
216 | 216 | if (!$this->hasGid()) { |
217 | 217 | throw new LogicException(static::class . " has no GID, it can't be reloaded."); |
218 | 218 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | 'user' => User::class |
19 | 19 | ]; |
20 | 20 | |
21 | - protected function _setData (array $data): void { |
|
21 | + protected function _setData(array $data): void { |
|
22 | 22 | // useless. likes aren't entities. |
23 | 23 | unset($data['gid'], $data['resource_type']); |
24 | 24 | parent::_setData($data); |
25 | 25 | } |
26 | 26 | |
27 | - final public function getResourceType (): string { |
|
27 | + final public function getResourceType(): string { |
|
28 | 28 | return self::TYPE; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |