@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param Task $task |
| 31 | 31 | * @param array $data |
| 32 | 32 | */ |
| 33 | - public function __construct (Task $task, array $data = []) { |
|
| 33 | + public function __construct(Task $task, array $data = []) { |
|
| 34 | 34 | $this->task = $task; |
| 35 | 35 | parent::__construct($task, $data); |
| 36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param mixed $value |
| 43 | 43 | * @return $this |
| 44 | 44 | */ |
| 45 | - protected function _set (string $field, $value) { |
|
| 45 | + protected function _set(string $field, $value) { |
|
| 46 | 46 | $this->task->diff['external'] = true; |
| 47 | 47 | return parent::_set($field, $value); |
| 48 | 48 | } |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return null|bool|number|string|array |
| 54 | 54 | */ |
| 55 | - public function getDataJsonDecoded () { |
|
| 55 | + public function getDataJsonDecoded() { |
|
| 56 | 56 | if (strlen($data = $this->getData())) { |
| 57 | - return json_decode($data, true, 512, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 57 | + return json_decode($data, true, 512, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 58 | 58 | } |
| 59 | 59 | return null; |
| 60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param mixed $data |
| 67 | 67 | * @return $this |
| 68 | 68 | */ |
| 69 | - public function setDataJsonEncoded ($data) { |
|
| 69 | + public function setDataJsonEncoded($data) { |
|
| 70 | 70 | if (isset($data)) { |
| 71 | 71 | return $this->setData(json_encode($data, JSON_THROW_ON_ERROR)); |
| 72 | 72 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | 'custom_field' => CustomField::class, |
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | - protected function _setData (array $data): void { |
|
| 26 | + protected function _setData(array $data): void { |
|
| 27 | 27 | // these are the only fields that matter. |
| 28 | 28 | parent::_setData([ |
| 29 | 29 | 'custom_field' => $data['custom_field'], |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * @return CustomField[] |
| 20 | 20 | */ |
| 21 | - public function getCustomFields () { |
|
| 21 | + public function getCustomFields() { |
|
| 22 | 22 | return array_column($this->getCustomFieldSettings(), 'custom_field'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -46,14 +46,14 @@ |
||
| 46 | 46 | /** |
| 47 | 47 | * @return Api |
| 48 | 48 | */ |
| 49 | - public static function getApi () { |
|
| 49 | + public static function getApi() { |
|
| 50 | 50 | return static::getFacadeRoot(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public static function getFacadeAccessor () { |
|
| 56 | + public static function getFacadeAccessor() { |
|
| 57 | 57 | return AsanaServiceProvider::NAME; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @param PSR16 $psr |
| 35 | 35 | */ |
| 36 | - public function __construct (PSR16 $psr) { |
|
| 36 | + public function __construct(PSR16 $psr) { |
|
| 37 | 37 | $this->psr = $psr; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param AbstractEntity $entity |
| 42 | 42 | * @throws CacheException |
| 43 | 43 | */ |
| 44 | - protected function _add (AbstractEntity $entity): void { |
|
| 44 | + protected function _add(AbstractEntity $entity): void { |
|
| 45 | 45 | $this->psr->set("asana/{$entity->getGid()}", $entity, $this->_getTtl($entity)); |
| 46 | 46 | parent::_add($entity); |
| 47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string[] $keys |
| 52 | 52 | * @throws CacheException |
| 53 | 53 | */ |
| 54 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
| 54 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
| 55 | 55 | $gid = $entity->getGid(); |
| 56 | 56 | $ttl = $this->_getTtl($entity); |
| 57 | 57 | foreach ($keys as $key) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return null|AbstractEntity |
| 69 | 69 | * @throws CacheException |
| 70 | 70 | */ |
| 71 | - protected function _get (string $key, $caller) { |
|
| 71 | + protected function _get(string $key, $caller) { |
|
| 72 | 72 | if (!$entity = parent::_get($key, $caller) and $entity = $this->psr->get("asana/{$key}")) { |
| 73 | 73 | if (is_string($entity)) { // gid ref |
| 74 | 74 | if (!$entity = $this->_get($entity, $caller)) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param AbstractEntity $entity |
| 89 | 89 | * @return int |
| 90 | 90 | */ |
| 91 | - protected function _getTtl (AbstractEntity $entity): int { |
|
| 91 | + protected function _getTtl(AbstractEntity $entity): int { |
|
| 92 | 92 | if ($entity instanceof ImmutableInterface) { |
| 93 | 93 | return strtotime('tomorrow') - time(); |
| 94 | 94 | } |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @return bool |
| 101 | 101 | * @throws CacheException |
| 102 | 102 | */ |
| 103 | - protected function _has (string $key): bool { |
|
| 103 | + protected function _has(string $key): bool { |
|
| 104 | 104 | return parent::_has($key) or $this->psr->has("asana/{$key}"); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | - public function getTtl (): int { |
|
| 110 | + public function getTtl(): int { |
|
| 111 | 111 | return $this->ttl; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string[] $keys |
| 116 | 116 | * @throws CacheException |
| 117 | 117 | */ |
| 118 | - public function remove (array $keys): void { |
|
| 118 | + public function remove(array $keys): void { |
|
| 119 | 119 | parent::remove($keys); |
| 120 | 120 | foreach ($keys as $key) { |
| 121 | 121 | $this->psr->delete("asana/{$key}"); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param int $ttl |
| 127 | 127 | * @return $this |
| 128 | 128 | */ |
| 129 | - public function setTtl (int $ttl) { |
|
| 129 | + public function setTtl(int $ttl) { |
|
| 130 | 130 | $this->ttl = $ttl; |
| 131 | 131 | return $this; |
| 132 | 132 | } |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | class Event extends Data { |
| 43 | 43 | |
| 44 | - const ACTION_CHANGED = 'changed'; // no parent |
|
| 45 | - const ACTION_ADDED = 'added'; // relational, no change |
|
| 46 | - const ACTION_REMOVED = 'removed'; // relational, no change |
|
| 47 | - const ACTION_DELETED = 'deleted'; // no parent or change |
|
| 48 | - const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
| 44 | + const ACTION_CHANGED = 'changed'; // no parent |
|
| 45 | + const ACTION_ADDED = 'added'; // relational, no change |
|
| 46 | + const ACTION_REMOVED = 'removed'; // relational, no change |
|
| 47 | + const ACTION_DELETED = 'deleted'; // no parent or change |
|
| 48 | + const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
| 49 | 49 | |
| 50 | 50 | const GRAPH = [ |
| 51 | 51 | User::TYPE => User::class, |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | 'user' => User::class |
| 64 | 64 | ]; |
| 65 | 65 | |
| 66 | - protected function _setData (array $data): void { |
|
| 66 | + protected function _setData(array $data): void { |
|
| 67 | 67 | if (isset($data['parent'])) { |
| 68 | 68 | $type = $data['parent']['resource_type']; |
| 69 | 69 | $data['parent'] = $this->_hydrate(static::GRAPH[$type], $data['parent']); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return null|Project|Section|Task |
| 82 | 82 | */ |
| 83 | - public function getParent () { |
|
| 83 | + public function getParent() { |
|
| 84 | 84 | return $this->data['parent'] ?? null; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -89,42 +89,42 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return User|Project|Section|Task|CustomField|Attachment|Story|Like |
| 91 | 91 | */ |
| 92 | - public function getResource () { |
|
| 92 | + public function getResource() { |
|
| 93 | 93 | return $this->data['resource']; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * @return bool |
| 98 | 98 | */ |
| 99 | - final public function wasAddition (): bool { |
|
| 99 | + final public function wasAddition(): bool { |
|
| 100 | 100 | return $this->getAction() === self::ACTION_ADDED; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * @return bool |
| 105 | 105 | */ |
| 106 | - final public function wasChange (): bool { |
|
| 106 | + final public function wasChange(): bool { |
|
| 107 | 107 | return $this->getAction() === self::ACTION_CHANGED; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * @return bool |
| 112 | 112 | */ |
| 113 | - final public function wasDeletion (): bool { |
|
| 113 | + final public function wasDeletion(): bool { |
|
| 114 | 114 | return $this->getAction() === self::ACTION_DELETED; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @return bool |
| 119 | 119 | */ |
| 120 | - final public function wasRemoval (): bool { |
|
| 120 | + final public function wasRemoval(): bool { |
|
| 121 | 121 | return $this->getAction() === self::ACTION_REMOVED; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * @return bool |
| 126 | 126 | */ |
| 127 | - final public function wasUndeletion (): bool { |
|
| 127 | + final public function wasUndeletion(): bool { |
|
| 128 | 128 | return $this->getAction() === self::ACTION_UNDELETED; |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param null|string|DateTimeInterface $date |
| 23 | 23 | * @return $this |
| 24 | 24 | */ |
| 25 | - private function _setYmd (string $field, $date) { |
|
| 25 | + private function _setYmd(string $field, $date) { |
|
| 26 | 26 | if ($date instanceof DateTimeInterface) { |
| 27 | 27 | $date = $date->format('Y-m-d'); |
| 28 | 28 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param null|string|DateTimeInterface $date |
| 34 | 34 | * @return $this |
| 35 | 35 | */ |
| 36 | - public function setDueOn ($date) { |
|
| 36 | + public function setDueOn($date) { |
|
| 37 | 37 | return $this->_setYmd('due_on', $date); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param null|string|DateTimeInterface $date |
| 42 | 42 | * @return $this |
| 43 | 43 | */ |
| 44 | - public function setStartOn ($date) { |
|
| 44 | + public function setStartOn($date) { |
|
| 45 | 45 | return $this->_setYmd('start_on', $date); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param array $diff |
| 20 | 20 | * @return $this |
| 21 | 21 | */ |
| 22 | - private function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
| 22 | + private function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
| 23 | 23 | if ($this->hasGid()) { |
| 24 | 24 | return $this->_setWithPost($addPath, $data, $field); |
| 25 | 25 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array|Closure $diff An array to diff, or a filter closure. |
| 34 | 34 | * @return $this |
| 35 | 35 | */ |
| 36 | - private function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
| 36 | + private function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
| 37 | 37 | if ($this->hasGid()) { |
| 38 | 38 | return $this->_setWithPost($rmPath, $data, $field); |
| 39 | 39 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return $this |
| 54 | 54 | * @internal |
| 55 | 55 | */ |
| 56 | - private function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
| 56 | + private function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
| 57 | 57 | if ($this->hasGid()) { |
| 58 | 58 | /** @var array $remote */ |
| 59 | 59 | $remote = $this->api->post($path, $data, ['fields' => static::OPT_FIELDS[$field] ?? $field]); |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | private function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
| 37 | 37 | if ($this->hasGid()) { |
| 38 | 38 | return $this->_setWithPost($rmPath, $data, $field); |
| 39 | - } |
|
| 40 | - elseif (is_array($diff)) { |
|
| 39 | + } elseif (is_array($diff)) { |
|
| 41 | 40 | return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
| 42 | 41 | } |
| 43 | 42 | return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff))); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected $key; |
| 42 | 42 | |
| 43 | - protected function _setData (array $data): void { |
|
| 43 | + protected function _setData(array $data): void { |
|
| 44 | 44 | $this->key = [ |
| 45 | 45 | Event::ACTION_ADDED => 'added_value', |
| 46 | 46 | Event::ACTION_REMOVED => 'removed_value', |
@@ -67,35 +67,35 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return null|User|Project|Section|Task|FieldEntry|Attachment|Story|Like |
| 69 | 69 | */ |
| 70 | - public function getPayload () { |
|
| 70 | + public function getPayload() { |
|
| 71 | 71 | return $this->data[$this->key]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - final public function hasPayload (): bool { |
|
| 77 | + final public function hasPayload(): bool { |
|
| 78 | 78 | return isset($this->data[$this->key]); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @return bool |
| 83 | 83 | */ |
| 84 | - final public function wasAddition (): bool { |
|
| 84 | + final public function wasAddition(): bool { |
|
| 85 | 85 | return $this->getAction() === Event::ACTION_ADDED; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return bool |
| 90 | 90 | */ |
| 91 | - final public function wasRemoval (): bool { |
|
| 91 | + final public function wasRemoval(): bool { |
|
| 92 | 92 | return $this->getAction() === Event::ACTION_REMOVED; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * @return bool |
| 97 | 97 | */ |
| 98 | - final public function wasValue (): bool { |
|
| 98 | + final public function wasValue(): bool { |
|
| 99 | 99 | return $this->getAction() === Event::ACTION_CHANGED; |
| 100 | 100 | } |
| 101 | 101 | |