@@ -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 |
@@ -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]); |
@@ -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)]; |
@@ -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 | } |
@@ -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 |
@@ -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']); |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | - abstract protected function _getDir (): string; |
|
| 19 | + abstract protected function _getDir(): string; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * `POST` the new entity to Asana. |
| 23 | 23 | * |
| 24 | 24 | * @return $this |
| 25 | 25 | */ |
| 26 | - public function create () { |
|
| 26 | + public function create() { |
|
| 27 | 27 | /** @var array $remote */ |
| 28 | 28 | $remote = $this->api->post($this->_getDir(), $this->toArray(true), ['expand' => 'this']); |
| 29 | 29 | $this->_setData($remote); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - final public function __toString (): string { |
|
| 42 | + final public function __toString(): string { |
|
| 43 | 43 | return "jobs/{$this->getGid()}"; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return bool |
| 50 | 50 | */ |
| 51 | - final public function isActive (): bool { |
|
| 51 | + final public function isActive(): bool { |
|
| 52 | 52 | return $this->getStatus() === self::STATUS_ACTIVE; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - final public function isDone (): bool { |
|
| 60 | + final public function isDone(): bool { |
|
| 61 | 61 | return $this->isSuccessful() or $this->isFailed(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - final public function isDuplicatingProject (): bool { |
|
| 67 | + final public function isDuplicatingProject(): bool { |
|
| 68 | 68 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_PROJECT; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return bool |
| 73 | 73 | */ |
| 74 | - final public function isDuplicatingTask (): bool { |
|
| 74 | + final public function isDuplicatingTask(): bool { |
|
| 75 | 75 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_TASK; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return bool |
| 82 | 82 | */ |
| 83 | - final public function isFailed (): bool { |
|
| 83 | + final public function isFailed(): bool { |
|
| 84 | 84 | return $this->getStatus() === self::STATUS_FAIL; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - final public function isQueued (): bool { |
|
| 92 | + final public function isQueued(): bool { |
|
| 93 | 93 | return $this->getStatus() === self::STATUS_QUEUED; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return bool |
| 100 | 100 | */ |
| 101 | - final public function isSuccessful (): bool { |
|
| 101 | + final public function isSuccessful(): bool { |
|
| 102 | 102 | return $this->getStatus() === self::STATUS_SUCCESS; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param callable $spinner `fn( Job $this ): void` |
| 111 | 111 | * @return $this |
| 112 | 112 | */ |
| 113 | - public function wait (callable $spinner = null) { |
|
| 113 | + public function wait(callable $spinner = null) { |
|
| 114 | 114 | while (!$this->isDone()) { |
| 115 | 115 | if ($spinner) { |
| 116 | 116 | call_user_func($spinner, $this); |