@@ -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 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
| 38 | - public static function random (): string { |
|
| 38 | + public static function random(): string { |
|
| 39 | 39 | try { |
| 40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
| 41 | 41 | return $colors[array_rand($colors)]; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | const NAME = 'asana'; |
| 19 | 19 | |
| 20 | - public function boot () { |
|
| 20 | + public function boot() { |
|
| 21 | 21 | $this->publishes([ |
| 22 | 22 | __DIR__ . '/config/asana.php' => $this->app->configPath('asana.php') |
| 23 | 23 | ]); |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function provides () { |
|
| 33 | + public function provides() { |
|
| 34 | 34 | return [self::NAME]; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function register () { |
|
| 37 | + public function register() { |
|
| 38 | 38 | $this->app->singleton(self::NAME, function(Application $app) { |
| 39 | 39 | $config = $app['config'][self::NAME]; |
| 40 | 40 | $pool = null; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | protected $curlInfo; |
| 22 | 22 | |
| 23 | - public function __construct (int $code, string $message, array $curlInfo) { |
|
| 23 | + public function __construct(int $code, string $message, array $curlInfo) { |
|
| 24 | 24 | parent::__construct($message, $code); |
| 25 | 25 | $this->curlInfo = $curlInfo; |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | - public function getCurlInfo (): array { |
|
| 31 | + public function getCurlInfo(): array { |
|
| 32 | 32 | return $this->curlInfo; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | $this->_log("CACHE DELINK {$key}"); |
| 59 | 59 | unlink($ref); |
| 60 | 60 | unlink($path); |
| 61 | - } |
|
| 62 | - elseif (is_file($path)) { |
|
| 61 | + } elseif (is_file($path)) { |
|
| 63 | 62 | $this->_log("CACHE DELETE {$key}"); |
| 64 | 63 | unlink($path); |
| 65 | 64 | } |
@@ -117,8 +116,7 @@ discard block |
||
| 117 | 116 | ["CACHE SET {$key}", "CACHE BURN {$key}"][$value instanceof ImmutableInterface], |
| 118 | 117 | "CACHE UPDATE {$key}" |
| 119 | 118 | ][is_file($path)]); |
| 120 | - } |
|
| 121 | - else { |
|
| 119 | + } else { |
|
| 122 | 120 | $this->_log([ |
| 123 | 121 | "CACHE LINK {$key} => {$value}", |
| 124 | 122 | "CACHE RENEW LINK {$key} => {$value}" |
@@ -29,30 +29,30 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param string $dir |
| 31 | 31 | */ |
| 32 | - public function __construct (string $dir) { |
|
| 32 | + public function __construct(string $dir) { |
|
| 33 | 33 | $this->dir = $dir; |
| 34 | 34 | $this->log = new NullLogger(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - private function _log (string $msg): void { |
|
| 37 | + private function _log(string $msg): void { |
|
| 38 | 38 | $this->log->log(LOG_DEBUG, $msg); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - private function _path ($key): string { |
|
| 41 | + private function _path($key): string { |
|
| 42 | 42 | $path = "{$this->dir}/{$key}~"; |
| 43 | 43 | clearstatcache(true, $path); |
| 44 | 44 | return $path; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - private function _ref ($key): string { |
|
| 47 | + private function _ref($key): string { |
|
| 48 | 48 | return "{$this->dir}/{$key}.ref"; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function clear () { |
|
| 51 | + public function clear() { |
|
| 52 | 52 | // unused. just delete the dir. |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function delete ($key) { |
|
| 55 | + public function delete($key) { |
|
| 56 | 56 | $path = $this->_path($key); |
| 57 | 57 | if (is_link($ref = $this->_ref($key))) { |
| 58 | 58 | $this->_log("CACHE DELINK {$key}"); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function deleteMultiple ($keys) { |
|
| 68 | + public function deleteMultiple($keys) { |
|
| 69 | 69 | // unused |
| 70 | 70 | } |
| 71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param mixed $default Unused. |
| 75 | 75 | * @return null|string|object |
| 76 | 76 | */ |
| 77 | - public function get ($key, $default = null) { |
|
| 77 | + public function get($key, $default = null) { |
|
| 78 | 78 | $path = $this->_path($key); |
| 79 | 79 | if (!is_file($path)) { |
| 80 | 80 | $this->_log("CACHE MISS {$key}"); |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | return $data; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function getMultiple ($keys, $default = null) { |
|
| 96 | + public function getMultiple($keys, $default = null) { |
|
| 97 | 97 | // unused |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function has ($key): bool { |
|
| 100 | + public function has($key): bool { |
|
| 101 | 101 | return is_file($this->_path($key)); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @param int $ttl |
| 108 | 108 | * @return void |
| 109 | 109 | */ |
| 110 | - public function set ($key, $value, $ttl = null): void { |
|
| 110 | + public function set($key, $value, $ttl = null): void { |
|
| 111 | 111 | $path = $this->_path($key); |
| 112 | 112 | if (!is_dir(dirname($path))) { |
| 113 | 113 | mkdir(dirname($path), 0770, true); |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | * @param LoggerInterface $log |
| 137 | 137 | * @return $this |
| 138 | 138 | */ |
| 139 | - public function setLog (LoggerInterface $log) { |
|
| 139 | + public function setLog(LoggerInterface $log) { |
|
| 140 | 140 | $this->log = $log; |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setMultiple ($values, $ttl = null) { |
|
| 144 | + public function setMultiple($values, $ttl = null) { |
|
| 145 | 145 | // unused |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param AbstractEntity $entity |
| 31 | 31 | */ |
| 32 | - protected function _add (AbstractEntity $entity): void { |
|
| 32 | + protected function _add(AbstractEntity $entity): void { |
|
| 33 | 33 | $gid = $entity->getGid(); |
| 34 | 34 | $this->entities[$gid] = $entity; |
| 35 | 35 | $this->gids[$gid] = $gid; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param AbstractEntity $entity |
| 40 | 40 | * @param string[] $keys |
| 41 | 41 | */ |
| 42 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
| 42 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
| 43 | 43 | $this->gids += array_fill_keys($keys, $entity->getGid()); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param Api|Data $caller For hydration if needed. |
| 49 | 49 | * @return null|AbstractEntity |
| 50 | 50 | */ |
| 51 | - protected function _get (string $key, $caller) { |
|
| 51 | + protected function _get(string $key, $caller) { |
|
| 52 | 52 | if (isset($this->gids[$key])) { |
| 53 | 53 | return $this->entities[$this->gids[$key]]; |
| 54 | 54 | } |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | * @param string $key |
| 63 | 63 | * @return bool |
| 64 | 64 | */ |
| 65 | - protected function _has (string $key): bool { |
|
| 65 | + protected function _has(string $key): bool { |
|
| 66 | 66 | return isset($this->gids[$key]); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param AbstractEntity $entity |
| 71 | 71 | */ |
| 72 | - final public function add (AbstractEntity $entity): void { |
|
| 72 | + final public function add(AbstractEntity $entity): void { |
|
| 73 | 73 | if (!$entity->isDiff()) { |
| 74 | 74 | $this->_add($entity); |
| 75 | 75 | $this->_addKeys($entity, ...$entity->getPoolKeys()); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param Closure $factory `fn( Api|Data $caller ): null|AbstractEntity` |
| 83 | 83 | * @return null|mixed|AbstractEntity |
| 84 | 84 | */ |
| 85 | - final public function get (string $key, $caller, Closure $factory) { |
|
| 85 | + final public function get(string $key, $caller, Closure $factory) { |
|
| 86 | 86 | /** @var AbstractEntity $entity */ |
| 87 | 87 | if (!$entity = $this->_get($key, $caller) and $entity = $factory($caller)) { |
| 88 | 88 | $gid = $entity->getGid(); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @param string[] $keys |
| 105 | 105 | */ |
| 106 | - public function remove (array $keys): void { |
|
| 106 | + public function remove(array $keys): void { |
|
| 107 | 107 | foreach ($keys as $key) { |
| 108 | 108 | unset($this->entities[$key]); |
| 109 | 109 | unset($this->gids[$key]); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * `DELETE` |
| 16 | 16 | */ |
| 17 | - public function delete (): void { |
|
| 17 | + public function delete(): void { |
|
| 18 | 18 | $this->api->delete($this); |
| 19 | 19 | $this->api->getPool()->remove($this->getPoolKeys()); |
| 20 | 20 | } |
@@ -49,8 +49,7 @@ discard block |
||
| 49 | 49 | public function __construct ($caller, array $data = []) { |
| 50 | 50 | if ($caller instanceof self) { |
| 51 | 51 | $this->api = $caller->api; |
| 52 | - } |
|
| 53 | - else { |
|
| 52 | + } else { |
|
| 54 | 53 | $this->api = $caller; |
| 55 | 54 | } |
| 56 | 55 | $this->_setData($data); |
@@ -242,8 +241,7 @@ discard block |
||
| 242 | 241 | $value = array_map(function($each) use ($class) { |
| 243 | 242 | return $this->_hydrate($class[0], $each); |
| 244 | 243 | }, $value); |
| 245 | - } |
|
| 246 | - elseif (isset($value)) { |
|
| 244 | + } elseif (isset($value)) { |
|
| 247 | 245 | $value = $this->_hydrate($class, $value); |
| 248 | 246 | } |
| 249 | 247 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param Api|Data $caller |
| 47 | 47 | * @param array $data |
| 48 | 48 | */ |
| 49 | - public function __construct ($caller, array $data = []) { |
|
| 49 | + public function __construct($caller, array $data = []) { |
|
| 50 | 50 | if ($caller instanceof self) { |
| 51 | 51 | $this->api = $caller->api; |
| 52 | 52 | } |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * @param array $args |
| 70 | 70 | * @return mixed |
| 71 | 71 | */ |
| 72 | - public function __call (string $method, array $args) { |
|
| 72 | + public function __call(string $method, array $args) { |
|
| 73 | 73 | static $magic = []; |
| 74 | - if (!$call =& $magic[$method]) { |
|
| 74 | + if (!$call = & $magic[$method]) { |
|
| 75 | 75 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
| 76 | 76 | if ('_select' !== $call[1] = '_' . $call[1]) { // _select() calls getters |
| 77 | 77 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return array |
| 87 | 87 | * @internal pool, `var_export()` |
| 88 | 88 | */ |
| 89 | - final public function __debugInfo (): array { |
|
| 89 | + final public function __debugInfo(): array { |
|
| 90 | 90 | return $this->data; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return null|Data|mixed |
| 96 | 96 | * @internal for `array_column()` |
| 97 | 97 | */ |
| 98 | - final public function __get ($field) { |
|
| 98 | + final public function __get($field) { |
|
| 99 | 99 | return $this->_get($field); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return bool |
| 105 | 105 | * @internal for `array_column()` |
| 106 | 106 | */ |
| 107 | - final public function __isset ($field) { |
|
| 107 | + final public function __isset($field) { |
|
| 108 | 108 | return true; // fields may be lazy-loaded or coalesced to null. |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param string $field |
| 117 | 117 | * @return mixed |
| 118 | 118 | */ |
| 119 | - protected function _get (string $field) { |
|
| 119 | + protected function _get(string $field) { |
|
| 120 | 120 | return $this->data[$field] ?? null; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $field |
| 132 | 132 | * @return bool |
| 133 | 133 | */ |
| 134 | - protected function _has (string $field): bool { |
|
| 134 | + protected function _has(string $field): bool { |
|
| 135 | 135 | $value = $this->_get($field); |
| 136 | 136 | if (isset($value)) { |
| 137 | 137 | if (is_countable($value)) { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param mixed $item |
| 150 | 150 | * @return mixed |
| 151 | 151 | */ |
| 152 | - protected function _hydrate (string $class, $item) { |
|
| 152 | + protected function _hydrate(string $class, $item) { |
|
| 153 | 153 | if (!isset($item) or $item instanceof self) { |
| 154 | 154 | return $item; |
| 155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param string $field |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - protected function _is (string $field): bool { |
|
| 181 | + protected function _is(string $field): bool { |
|
| 182 | 182 | return (bool)$this->_get($field); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $args |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | - protected function _select ($subject, callable $filter, ...$args) { |
|
| 199 | + protected function _select($subject, callable $filter, ...$args) { |
|
| 200 | 200 | if (is_string($subject)) { |
| 201 | 201 | $subject = $this->{'get' . $subject}(...$args) ?? []; |
| 202 | 202 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param mixed $value |
| 219 | 219 | * @return $this |
| 220 | 220 | */ |
| 221 | - protected function _set (string $field, $value) { |
|
| 221 | + protected function _set(string $field, $value) { |
|
| 222 | 222 | $this->data[$field] = $value; |
| 223 | 223 | $this->diff[$field] = true; |
| 224 | 224 | return $this; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param array $data |
| 231 | 231 | */ |
| 232 | - protected function _setData (array $data): void { |
|
| 232 | + protected function _setData(array $data): void { |
|
| 233 | 233 | $this->data = $this->diff = []; |
| 234 | 234 | foreach ($data as $field => $value) { |
| 235 | 235 | $this->_setField($field, $value); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param string $field |
| 243 | 243 | * @param mixed $value |
| 244 | 244 | */ |
| 245 | - protected function _setField (string $field, $value): void { |
|
| 245 | + protected function _setField(string $field, $value): void { |
|
| 246 | 246 | if (isset(static::MAP[$field])) { |
| 247 | 247 | $class = static::MAP[$field]; |
| 248 | 248 | if (is_array($class)) { |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return bool |
| 265 | 265 | */ |
| 266 | - final public function isDiff (): bool { |
|
| 266 | + final public function isDiff(): bool { |
|
| 267 | 267 | return (bool)$this->diff; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @return array |
| 272 | 272 | */ |
| 273 | - public function jsonSerialize (): array { |
|
| 273 | + public function jsonSerialize(): array { |
|
| 274 | 274 | $data = $this->toArray(); |
| 275 | 275 | ksort($data); |
| 276 | 276 | return $data; |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | - public function serialize (): string { |
|
| 285 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
| 284 | + public function serialize(): string { |
|
| 285 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param bool $diff |
| 292 | 292 | * @return array |
| 293 | 293 | */ |
| 294 | - public function toArray (bool $diff = false): array { |
|
| 294 | + public function toArray(bool $diff = false): array { |
|
| 295 | 295 | $dehydrate = function($each) use (&$dehydrate, $diff) { |
| 296 | 296 | // convert entities to gids |
| 297 | 297 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | /** |
| 318 | 318 | * @param $serialized |
| 319 | 319 | */ |
| 320 | - public function unserialize ($serialized): void { |
|
| 320 | + public function unserialize($serialized): void { |
|
| 321 | 321 | $this->data = json_decode($serialized, true); |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | \ No newline at end of file |
@@ -484,8 +484,7 @@ |
||
| 484 | 484 | 'sync' => $token, |
| 485 | 485 | 'opt_expand' => 'this' |
| 486 | 486 | ])); |
| 487 | - } |
|
| 488 | - catch (AsanaError $error) { |
|
| 487 | + } catch (AsanaError $error) { |
|
| 489 | 488 | if ($error->getCode() === 412) { |
| 490 | 489 | $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
| 491 | 490 | if (!isset($token)) { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $token |
| 44 | 44 | * @param null|Pool $pool |
| 45 | 45 | */ |
| 46 | - public function __construct (string $token, Pool $pool = null) { |
|
| 46 | + public function __construct(string $token, Pool $pool = null) { |
|
| 47 | 47 | $this->token = $token; |
| 48 | 48 | $this->pool = $pool ?? new Pool(); |
| 49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return null|array |
| 58 | 58 | * @internal |
| 59 | 59 | */ |
| 60 | - protected function _exec (string $method, string $path, array $curlOpts = []) { |
|
| 60 | + protected function _exec(string $method, string $path, array $curlOpts = []) { |
|
| 61 | 61 | $log = $this->getLog(); |
| 62 | 62 | $log->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
| 63 | 63 | /** @var resource $ch */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | switch ($curlInfo['http_code']) { |
| 89 | 89 | case 200: |
| 90 | 90 | case 201: |
| 91 | - return json_decode($body, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 91 | + return json_decode($body, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 92 | 92 | case 404: |
| 93 | 93 | return null; |
| 94 | 94 | case 429: |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param string $path |
| 109 | 109 | */ |
| 110 | - public function delete (string $path): void { |
|
| 110 | + public function delete(string $path): void { |
|
| 111 | 111 | $this->_exec('DELETE', $path); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param array $data |
| 122 | 122 | * @return mixed|Data|AbstractEntity |
| 123 | 123 | */ |
| 124 | - public function factory ($caller, string $class, array $data = []) { |
|
| 124 | + public function factory($caller, string $class, array $data = []) { |
|
| 125 | 125 | return new $class($caller, $data); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param array $opt |
| 134 | 134 | * @return null|array |
| 135 | 135 | */ |
| 136 | - public function get (string $path, array $query = [], array $opt = []) { |
|
| 136 | + public function get(string $path, array $query = [], array $opt = []) { |
|
| 137 | 137 | foreach ($opt as $name => $value) { |
| 138 | 138 | $query["opt_{$name}"] = $value; |
| 139 | 139 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $gid |
| 148 | 148 | * @return null|Attachment |
| 149 | 149 | */ |
| 150 | - public function getAttachment (string $gid) { |
|
| 150 | + public function getAttachment(string $gid) { |
|
| 151 | 151 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $gid |
| 158 | 158 | * @return null|CustomField |
| 159 | 159 | */ |
| 160 | - public function getCustomField (string $gid) { |
|
| 160 | + public function getCustomField(string $gid) { |
|
| 161 | 161 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -168,28 +168,28 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return Workspace |
| 170 | 170 | */ |
| 171 | - public function getDefaultWorkspace () { |
|
| 171 | + public function getDefaultWorkspace() { |
|
| 172 | 172 | return $this->getMe()->getDefaultWorkspace(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * @return LoggerInterface |
| 177 | 177 | */ |
| 178 | - public function getLog () { |
|
| 178 | + public function getLog() { |
|
| 179 | 179 | return $this->log ?? $this->log = new NullLogger(); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @return User |
| 184 | 184 | */ |
| 185 | - public function getMe () { |
|
| 185 | + public function getMe() { |
|
| 186 | 186 | return $this->getUser('me'); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * @return Pool |
| 191 | 191 | */ |
| 192 | - public function getPool () { |
|
| 192 | + public function getPool() { |
|
| 193 | 193 | return $this->pool; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $gid |
| 200 | 200 | * @return null|Portfolio |
| 201 | 201 | */ |
| 202 | - public function getPortfolio (string $gid) { |
|
| 202 | + public function getPortfolio(string $gid) { |
|
| 203 | 203 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param string $gid |
| 210 | 210 | * @return null|Project |
| 211 | 211 | */ |
| 212 | - public function getProject (string $gid) { |
|
| 212 | + public function getProject(string $gid) { |
|
| 213 | 213 | return $this->load($this, Project::class, "projects/{$gid}"); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @param string $gid |
| 220 | 220 | * @return null|Section |
| 221 | 221 | */ |
| 222 | - public function getSection (string $gid) { |
|
| 222 | + public function getSection(string $gid) { |
|
| 223 | 223 | return $this->load($this, Section::class, "sections/{$gid}"); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string $gid |
| 230 | 230 | * @return null|Story |
| 231 | 231 | */ |
| 232 | - public function getStory (string $gid) { |
|
| 232 | + public function getStory(string $gid) { |
|
| 233 | 233 | return $this->load($this, Story::class, "stories/{$gid}"); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string $gid |
| 240 | 240 | * @return null|Tag |
| 241 | 241 | */ |
| 242 | - public function getTag (string $gid) { |
|
| 242 | + public function getTag(string $gid) { |
|
| 243 | 243 | return $this->load($this, Tag::class, "tags/{$gid}"); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param string $gid |
| 250 | 250 | * @return null|Task |
| 251 | 251 | */ |
| 252 | - public function getTask (string $gid) { |
|
| 252 | + public function getTask(string $gid) { |
|
| 253 | 253 | return $this->load($this, Task::class, "tasks/{$gid}"); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param string $gid |
| 260 | 260 | * @return null|TaskList |
| 261 | 261 | */ |
| 262 | - public function getTaskList (string $gid) { |
|
| 262 | + public function getTaskList(string $gid) { |
|
| 263 | 263 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param string $gid |
| 270 | 270 | * @return null|Team |
| 271 | 271 | */ |
| 272 | - public function getTeam (string $gid) { |
|
| 272 | + public function getTeam(string $gid) { |
|
| 273 | 273 | return $this->load($this, Team::class, "teams/{$gid}"); |
| 274 | 274 | } |
| 275 | 275 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @param string $gid |
| 280 | 280 | * @return null|User |
| 281 | 281 | */ |
| 282 | - public function getUser (string $gid) { |
|
| 282 | + public function getUser(string $gid) { |
|
| 283 | 283 | return $this->load($this, User::class, "users/{$gid}"); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @param string $gid |
| 288 | 288 | * @return ProjectWebhook|TaskWebhook |
| 289 | 289 | */ |
| 290 | - public function getWebhook (string $gid) { |
|
| 290 | + public function getWebhook(string $gid) { |
|
| 291 | 291 | return $this->pool->get($gid, $this, function() use ($gid) { |
| 292 | 292 | static $classes = [ |
| 293 | 293 | Project::TYPE => ProjectWebhook::class, |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param array $data |
| 309 | 309 | * @return Event |
| 310 | 310 | */ |
| 311 | - public function getWebhookEvent (array $data) { |
|
| 311 | + public function getWebhookEvent(array $data) { |
|
| 312 | 312 | return $this->factory($this, Event::class, $data); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @param string $gid |
| 319 | 319 | * @return null|Workspace |
| 320 | 320 | */ |
| 321 | - public function getWorkspace (string $gid) { |
|
| 321 | + public function getWorkspace(string $gid) { |
|
| 322 | 322 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param array $query |
| 332 | 332 | * @return null|mixed|AbstractEntity |
| 333 | 333 | */ |
| 334 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
| 334 | + public function load($caller, string $class, string $path, array $query = []) { |
|
| 335 | 335 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
| 336 | 336 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 337 | 337 | if ($data = $this->get($path, $query, ['expand' => 'this'])) { |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param array $query |
| 351 | 351 | * @return array|AbstractEntity[] |
| 352 | 352 | */ |
| 353 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
| 353 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
| 354 | 354 | return iterator_to_array($this->loadEach(...func_get_args())); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param array $query `limit` can exceed `100` here. |
| 366 | 366 | * @return Generator|AbstractEntity[] |
| 367 | 367 | */ |
| 368 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
| 368 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
| 369 | 369 | $query['opt_expand'] = 'this'; |
| 370 | 370 | $remain = $query['limit'] ?? PHP_INT_MAX; |
| 371 | 371 | do { |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | * @param array $opt |
| 390 | 390 | * @return null|array |
| 391 | 391 | */ |
| 392 | - public function post (string $path, array $data = [], array $opt = []) { |
|
| 392 | + public function post(string $path, array $data = [], array $opt = []) { |
|
| 393 | 393 | $response = $this->_exec('POST', $path, [ |
| 394 | 394 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 395 | 395 | CURLOPT_POSTFIELDS => json_encode([ |
| 396 | 396 | 'options' => $opt, |
| 397 | 397 | 'data' => $data |
| 398 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
| 398 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
| 399 | 399 | ]); |
| 400 | 400 | return $response['data'] ?? null; |
| 401 | 401 | } |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | * @param array $opt |
| 409 | 409 | * @return null|array |
| 410 | 410 | */ |
| 411 | - public function put (string $path, array $data = [], array $opt = []) { |
|
| 411 | + public function put(string $path, array $data = [], array $opt = []) { |
|
| 412 | 412 | $response = $this->_exec('PUT', $path, [ |
| 413 | 413 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 414 | 414 | CURLOPT_POSTFIELDS => json_encode([ |
| 415 | 415 | 'options' => $opt, |
| 416 | 416 | 'data' => $data |
| 417 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
| 417 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
| 418 | 418 | ]); |
| 419 | 419 | return $response['data'] ?? null; |
| 420 | 420 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | /** |
| 423 | 423 | * @param LoggerInterface $log |
| 424 | 424 | */ |
| 425 | - public function setLog (LoggerInterface $log) { |
|
| 425 | + public function setLog(LoggerInterface $log) { |
|
| 426 | 426 | $this->log = $log; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @param null|string $token Updated to the new token. |
| 439 | 439 | * @return Event[] |
| 440 | 440 | */ |
| 441 | - public function sync (string $gid, ?string &$token) { |
|
| 441 | + public function sync(string $gid, ?string &$token) { |
|
| 442 | 442 | try { |
| 443 | 443 | /** @var array $remote Asana throws 400 for missing entities. */ |
| 444 | 444 | $remote = $this->_exec('GET', 'events?' . http_build_query([ |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | catch (AsanaError $error) { |
| 451 | 451 | if ($error->getCode() === 412) { |
| 452 | - $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 452 | + $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 453 | 453 | if (!isset($token)) { |
| 454 | 454 | // API docs say: "The response will be the same as for an expired sync token." |
| 455 | 455 | // The caller knowingly gave a null token, so we don't need to rethrow. |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $to |
| 479 | 479 | * @return array |
| 480 | 480 | */ |
| 481 | - public function upload (string $file, string $to) { |
|
| 481 | + public function upload(string $file, string $to) { |
|
| 482 | 482 | return $this->_exec('POST', $to, [ |
| 483 | 483 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 484 | 484 | ])['data']; |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @return $this |
| 18 | 18 | */ |
| 19 | - public function update () { |
|
| 19 | + public function update() { |
|
| 20 | 20 | if ($this->isDiff()) { |
| 21 | 21 | /** @var array $remote */ |
| 22 | 22 | $remote = $this->api->put($this, $this->toArray(true), ['expand' => 'this']); |