@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | 'workspace' => Workspace::class |
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | - final public function __toString (): string { |
|
| 33 | + final public function __toString(): string { |
|
| 34 | 34 | return "user_task_lists/{$this->getGid()}"; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function getCacheKeys () { |
|
| 37 | + public function getCacheKeys() { |
|
| 38 | 38 | $keys = parent::getCacheKeys(); |
| 39 | 39 | |
| 40 | 40 | /** @see User::getTaskList() */ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * @return Task[] |
| 50 | 50 | */ |
| 51 | - public function getIncompleteTasks () { |
|
| 51 | + public function getIncompleteTasks() { |
|
| 52 | 52 | return $this->getTasks(['completed_since' => 'now']); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return ArrayIterator|Task[] |
| 59 | 59 | */ |
| 60 | - public function getIterator () { |
|
| 60 | + public function getIterator() { |
|
| 61 | 61 | return new ArrayIterator($this->getTasks()); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param array $filter |
| 70 | 70 | * @return Task[] |
| 71 | 71 | */ |
| 72 | - public function getTasks (array $filter = []) { |
|
| 72 | + public function getTasks(array $filter = []) { |
|
| 73 | 73 | return $this->loadAll(Task::class, "{$this}/tasks", $filter); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'workspaces' => [Workspace::class] |
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | - final public function __toString (): string { |
|
| 31 | + final public function __toString(): string { |
|
| 32 | 32 | return "users/{$this->getGid()}"; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param Workspace $workspace |
| 37 | 37 | * @return $this |
| 38 | 38 | */ |
| 39 | - public function addToWorkspace (Workspace $workspace) { |
|
| 39 | + public function addToWorkspace(Workspace $workspace) { |
|
| 40 | 40 | return $this->_addWithPost("{$workspace}/addUser", [ |
| 41 | 41 | 'user' => $this->getGid() |
| 42 | 42 | ], 'workspaces', [$workspace]); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @return string[] |
| 47 | 47 | */ |
| 48 | - public function getCacheKeys () { |
|
| 48 | + public function getCacheKeys() { |
|
| 49 | 49 | $keys = parent::getCacheKeys(); |
| 50 | 50 | |
| 51 | 51 | // only include email as a key if it's loaded |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return Workspace |
| 64 | 64 | */ |
| 65 | - public function getDefaultWorkspace () { |
|
| 65 | + public function getDefaultWorkspace() { |
|
| 66 | 66 | return $this->getWorkspaces()[0]; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 71 | 71 | * @return Portfolio[] |
| 72 | 72 | */ |
| 73 | - public function getFavoritePortfolios (Workspace $workspace = null) { |
|
| 73 | + public function getFavoritePortfolios(Workspace $workspace = null) { |
|
| 74 | 74 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 79 | 79 | * @return Project[] |
| 80 | 80 | */ |
| 81 | - public function getFavoriteProjects (Workspace $workspace = null) { |
|
| 81 | + public function getFavoriteProjects(Workspace $workspace = null) { |
|
| 82 | 82 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 87 | 87 | * @return Tag[] |
| 88 | 88 | */ |
| 89 | - public function getFavoriteTags (Workspace $workspace = null) { |
|
| 89 | + public function getFavoriteTags(Workspace $workspace = null) { |
|
| 90 | 90 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 95 | 95 | * @return Team[] |
| 96 | 96 | */ |
| 97 | - public function getFavoriteTeams (Workspace $workspace = null) { |
|
| 97 | + public function getFavoriteTeams(Workspace $workspace = null) { |
|
| 98 | 98 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 103 | 103 | * @return User[] |
| 104 | 104 | */ |
| 105 | - public function getFavoriteUsers (Workspace $workspace = null) { |
|
| 105 | + public function getFavoriteUsers(Workspace $workspace = null) { |
|
| 106 | 106 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 113 | 113 | * @return array |
| 114 | 114 | */ |
| 115 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) { |
|
| 115 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) { |
|
| 116 | 116 | return $this->loadAll($class, "{$this}/favorites", [ |
| 117 | 117 | 'resource_type' => $resourceType, |
| 118 | 118 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 128 | 128 | * @return Task[] |
| 129 | 129 | */ |
| 130 | - public function getIncompleteTasks (Workspace $workspace = null) { |
|
| 130 | + public function getIncompleteTasks(Workspace $workspace = null) { |
|
| 131 | 131 | $filter = ['completed_since' => 'now']; |
| 132 | 132 | if ($workspace) { |
| 133 | 133 | $filter['workspace'] = $workspace->getGid(); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param null|Workspace $workspace |
| 140 | 140 | * @return Portfolio[] |
| 141 | 141 | */ |
| 142 | - public function getPortfolios (Workspace $workspace = null) { |
|
| 142 | + public function getPortfolios(Workspace $workspace = null) { |
|
| 143 | 143 | return $this->loadAll(Portfolio::class, "portfolios", [ |
| 144 | 144 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid(), |
| 145 | 145 | 'owner' => $this->getGid() |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 151 | 151 | * @return TaskList |
| 152 | 152 | */ |
| 153 | - public function getTaskList (Workspace $workspace = null) { |
|
| 153 | + public function getTaskList(Workspace $workspace = null) { |
|
| 154 | 154 | return $this->load(TaskList::class, "{$this}/user_task_list", [ |
| 155 | 155 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
| 156 | 156 | ]); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param string[] $filter `workspace` falls back to the default. |
| 165 | 165 | * @return Task[] |
| 166 | 166 | */ |
| 167 | - public function getTasks (array $filter = []) { |
|
| 167 | + public function getTasks(array $filter = []) { |
|
| 168 | 168 | $filter['assignee'] = $this->getGid(); |
| 169 | 169 | $filter += ['workspace' => $this->getDefaultWorkspace()->getGid()]; |
| 170 | 170 | return $this->loadAll(Task::class, 'tasks', $filter); |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | * @param null|Workspace $organization Falls back to the default workspace. |
| 179 | 179 | * @return Team[] |
| 180 | 180 | */ |
| 181 | - public function getTeams (Workspace $organization = null) { |
|
| 181 | + public function getTeams(Workspace $organization = null) { |
|
| 182 | 182 | return $this->loadAll(Team::class, "{$this}/teams", [ |
| 183 | 183 | 'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid() |
| 184 | 184 | ]); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public function getUrl (): string { |
|
| 187 | + public function getUrl(): string { |
|
| 188 | 188 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param Workspace $workspace |
| 193 | 193 | * @return $this |
| 194 | 194 | */ |
| 195 | - public function removeFromWorkspace (Workspace $workspace) { |
|
| 195 | + public function removeFromWorkspace(Workspace $workspace) { |
|
| 196 | 196 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
| 197 | 197 | 'user' => $this->getGid() |
| 198 | 198 | ], 'workspaces', [$workspace]); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param array $apiFilter Given to the API to reduce network load. |
| 204 | 204 | * @return Task[] |
| 205 | 205 | */ |
| 206 | - public function selectTasks (callable $filter, array $apiFilter) { |
|
| 206 | + public function selectTasks(callable $filter, array $apiFilter) { |
|
| 207 | 207 | return $this->_select($this->getTasks($apiFilter), $filter); |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | \ No newline at end of file |
@@ -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 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - abstract public function __toString (): string; |
|
| 28 | + abstract public function __toString(): string; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param AbstractEntity $entity |
| 46 | 46 | * @internal |
| 47 | 47 | */ |
| 48 | - public function __set (string $from, self $entity) { |
|
| 48 | + public function __set(string $from, self $entity) { |
|
| 49 | 49 | if ($from === Cache::class and $entity !== $this) { |
| 50 | 50 | foreach ($entity->data as $field => $value) { |
| 51 | 51 | if (!isset($this->diff[$field])) { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @return $this |
| 64 | 64 | * @internal |
| 65 | 65 | */ |
| 66 | - protected function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
| 66 | + protected function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
| 67 | 67 | if ($this->hasGid()) { |
| 68 | 68 | return $this->_setWithPost($addPath, $data, $field); |
| 69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @internal |
| 77 | 77 | */ |
| 78 | - protected function _cache (): void { |
|
| 78 | + protected function _cache(): void { |
|
| 79 | 79 | $this->api->getCache()->add($this); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @internal |
| 86 | 86 | */ |
| 87 | - protected function _delete (): void { |
|
| 87 | + protected function _delete(): void { |
|
| 88 | 88 | $this->api->delete($this); |
| 89 | 89 | $this->api->getCache()->remove($this); |
| 90 | 90 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $field |
| 96 | 96 | * @return mixed |
| 97 | 97 | */ |
| 98 | - protected function _get (string $field) { |
|
| 98 | + protected function _get(string $field) { |
|
| 99 | 99 | if (!array_key_exists($field, $this->data) and isset($this->data['gid'])) { |
| 100 | 100 | $this->reload($field); |
| 101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @return $this |
| 111 | 111 | * @internal |
| 112 | 112 | */ |
| 113 | - protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
| 113 | + protected function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
| 114 | 114 | if ($this->hasGid()) { |
| 115 | 115 | return $this->_setWithPost($rmPath, $data, $field); |
| 116 | 116 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return $this |
| 128 | 128 | * @internal |
| 129 | 129 | */ |
| 130 | - protected function _save (string $dir = null) { |
|
| 130 | + protected function _save(string $dir = null) { |
|
| 131 | 131 | if (isset($dir)) { |
| 132 | 132 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
| 133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | return $this; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - protected function _setData (array $data): void { |
|
| 146 | + protected function _setData(array $data): void { |
|
| 147 | 147 | // the resource type is constant. there's no need to keep it per-instance. |
| 148 | 148 | unset($data['resource_type']); |
| 149 | 149 | parent::_setData($data); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @return $this |
| 160 | 160 | * @internal |
| 161 | 161 | */ |
| 162 | - protected function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
| 162 | + protected function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
| 163 | 163 | if ($this->hasGid()) { |
| 164 | 164 | /** @var array $remote */ |
| 165 | 165 | $remote = $this->api->post($path, $data, ['fields' => static::$optFields[$field] ?? $field]); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @return string[] |
| 179 | 179 | */ |
| 180 | - public function getCacheKeys () { |
|
| 180 | + public function getCacheKeys() { |
|
| 181 | 181 | return [$this->getGid(), (string)$this]; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - final public function getResourceType (): string { |
|
| 189 | + final public function getResourceType(): string { |
|
| 190 | 190 | return $this::TYPE; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param string $field |
| 198 | 198 | * @return $this |
| 199 | 199 | */ |
| 200 | - public function reload (string $field = null) { |
|
| 200 | + public function reload(string $field = null) { |
|
| 201 | 201 | if (!$this->hasGid()) { |
| 202 | 202 | throw new LogicException(static::class . " has no GID, it can't be reloaded."); |
| 203 | 203 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | 'memberships' => 'memberships.(project|section)' |
| 96 | 96 | ]; |
| 97 | 97 | |
| 98 | - final public function __toString (): string { |
|
| 98 | + final public function __toString(): string { |
|
| 99 | 99 | return "tasks/{$this->getGid()}"; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - final protected function _getDir (): string { |
|
| 102 | + final protected function _getDir(): string { |
|
| 103 | 103 | return 'tasks'; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - protected function _save (string $dir = null) { |
|
| 106 | + protected function _save(string $dir = null) { |
|
| 107 | 107 | parent::_save($dir); |
| 108 | 108 | // use isset() to avoid has() fetch. |
| 109 | 109 | if (isset($this->data['custom_fields'])) { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - protected function _setData (array $data): void { |
|
| 118 | + protected function _setData(array $data): void { |
|
| 119 | 119 | // hearts were deprecated for likes |
| 120 | 120 | unset($data['hearted'], $data['hearts']); |
| 121 | 121 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param string $file |
| 133 | 133 | * @return Attachment |
| 134 | 134 | */ |
| 135 | - public function addAttachment (string $file) { |
|
| 135 | + public function addAttachment(string $file) { |
|
| 136 | 136 | /** @var Attachment $attachment */ |
| 137 | 137 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
| 138 | 138 | return $attachment->upload($file); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $text |
| 145 | 145 | * @return Story |
| 146 | 146 | */ |
| 147 | - public function addComment (string $text) { |
|
| 147 | + public function addComment(string $text) { |
|
| 148 | 148 | return $this->newComment()->setText($text)->create(); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param Task[] $tasks |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function addDependencies (array $tasks) { |
|
| 158 | + public function addDependencies(array $tasks) { |
|
| 159 | 159 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
| 160 | 160 | return $this; |
| 161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param Task $task |
| 168 | 168 | * @return $this |
| 169 | 169 | */ |
| 170 | - public function addDependency (Task $task) { |
|
| 170 | + public function addDependency(Task $task) { |
|
| 171 | 171 | return $this->addDependencies([$task]); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param Task $task |
| 179 | 179 | * @return $this |
| 180 | 180 | */ |
| 181 | - public function addDependent (Task $task) { |
|
| 181 | + public function addDependent(Task $task) { |
|
| 182 | 182 | return $this->addDependents([$task]); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param Task[] $tasks |
| 190 | 190 | * @return $this |
| 191 | 191 | */ |
| 192 | - public function addDependents (array $tasks) { |
|
| 192 | + public function addDependents(array $tasks) { |
|
| 193 | 193 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 194 | 194 | return $this; |
| 195 | 195 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param User $user |
| 201 | 201 | * @return $this |
| 202 | 202 | */ |
| 203 | - public function addFollower (User $user) { |
|
| 203 | + public function addFollower(User $user) { |
|
| 204 | 204 | return $this->addFollowers([$user]); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param User[] $users |
| 213 | 213 | * @return $this |
| 214 | 214 | */ |
| 215 | - public function addFollowers (array $users) { |
|
| 215 | + public function addFollowers(array $users) { |
|
| 216 | 216 | return $this->_addWithPost("{$this}/addFollowers", [ |
| 217 | 217 | 'followers' => array_column($users, 'gid') |
| 218 | 218 | ], 'followers', $users); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @param Tag $tag |
| 227 | 227 | * @return $this |
| 228 | 228 | */ |
| 229 | - public function addTag (Tag $tag) { |
|
| 229 | + public function addTag(Tag $tag) { |
|
| 230 | 230 | return $this->_addWithPost("{$this}/addTag", [ |
| 231 | 231 | 'tag' => $tag->getGid() |
| 232 | 232 | ], 'tags', [$tag]); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param Section|null $section |
| 242 | 242 | * @return $this |
| 243 | 243 | */ |
| 244 | - public function addToProject (Project $project, Section $section = null) { |
|
| 244 | + public function addToProject(Project $project, Section $section = null) { |
|
| 245 | 245 | /** @var Membership $membership */ |
| 246 | 246 | $membership = $this->factory(Membership::class) |
| 247 | 247 | ->_set('project', $project) |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string $target |
| 257 | 257 | * @return TaskWebhook |
| 258 | 258 | */ |
| 259 | - public function addWebhook (string $target) { |
|
| 259 | + public function addWebhook(string $target) { |
|
| 260 | 260 | /** @var TaskWebhook $webhook */ |
| 261 | 261 | $webhook = $this->factory(TaskWebhook::class); |
| 262 | 262 | return $webhook->create($this, $target); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param string[] $include |
| 273 | 273 | * @return Job |
| 274 | 274 | */ |
| 275 | - public function duplicate (string $name, array $include) { |
|
| 275 | + public function duplicate(string $name, array $include) { |
|
| 276 | 276 | /** @var array $remote */ |
| 277 | 277 | $remote = $this->api->post("{$this}/duplicate", [ |
| 278 | 278 | 'name' => $name, |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @depends after-create |
| 288 | 288 | * @return Attachment[] |
| 289 | 289 | */ |
| 290 | - public function getAttachments () { |
|
| 290 | + public function getAttachments() { |
|
| 291 | 291 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @depends after-create |
| 298 | 298 | * @return Story[] |
| 299 | 299 | */ |
| 300 | - public function getComments () { |
|
| 300 | + public function getComments() { |
|
| 301 | 301 | return $this->selectStories(function(Story $story) { |
| 302 | 302 | return $story->isComment(); |
| 303 | 303 | }); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @depends after-create |
| 310 | 310 | * @return Task[] |
| 311 | 311 | */ |
| 312 | - public function getDependencies () { |
|
| 312 | + public function getDependencies() { |
|
| 313 | 313 | return $this->loadAll(self::class, "{$this}/dependencies"); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @depends after-create |
| 320 | 320 | * @return Task[] |
| 321 | 321 | */ |
| 322 | - public function getDependents () { |
|
| 322 | + public function getDependents() { |
|
| 323 | 323 | return $this->loadAll(self::class, "{$this}/dependents"); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param null|string $token |
| 331 | 331 | * @return TaskEvent[]|StoryEvent[] |
| 332 | 332 | */ |
| 333 | - public function getEvents (&$token) { |
|
| 333 | + public function getEvents(&$token) { |
|
| 334 | 334 | return $this->api->sync($this, $token); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @return External |
| 344 | 344 | */ |
| 345 | - public function getExternal () { |
|
| 345 | + public function getExternal() { |
|
| 346 | 346 | return $this->_get('external') ?? $this->data['external'] = $this->factory(External::class); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
| 350 | 350 | * @return Project[] |
| 351 | 351 | */ |
| 352 | - public function getProjects () { |
|
| 352 | + public function getProjects() { |
|
| 353 | 353 | return array_map(function(Membership $membership) { |
| 354 | 354 | return $membership->getProject(); |
| 355 | 355 | }, $this->getMemberships()); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @depends after-create |
| 362 | 362 | * @return Story[] |
| 363 | 363 | */ |
| 364 | - public function getStories () { |
|
| 364 | + public function getStories() { |
|
| 365 | 365 | return $this->loadAll(Story::class, "{$this}/stories"); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @depends after-create |
| 372 | 372 | * @return Task[] |
| 373 | 373 | */ |
| 374 | - public function getSubTasks () { |
|
| 374 | + public function getSubTasks() { |
|
| 375 | 375 | return $this->loadAll(self::class, "{$this}/subtasks"); |
| 376 | 376 | } |
| 377 | 377 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | * @depends after-create |
| 382 | 382 | * @return string |
| 383 | 383 | */ |
| 384 | - public function getUrl (): string { |
|
| 384 | + public function getUrl(): string { |
|
| 385 | 385 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 386 | 386 | } |
| 387 | 387 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * @depends after-create |
| 392 | 392 | * @return TaskWebhook[] |
| 393 | 393 | */ |
| 394 | - public function getWebhooks () { |
|
| 394 | + public function getWebhooks() { |
|
| 395 | 395 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
| 396 | 396 | 'workspace' => $this->getWorkspace()->getGid(), |
| 397 | 397 | 'resource' => $this->getGid() |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | /** |
| 402 | 402 | * @return bool |
| 403 | 403 | */ |
| 404 | - public function isRenderedAsSeparator (): bool { |
|
| 404 | + public function isRenderedAsSeparator(): bool { |
|
| 405 | 405 | return $this->_is('is_rendered_as_separator'); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @depends after-create |
| 412 | 412 | * @return Story |
| 413 | 413 | */ |
| 414 | - public function newComment () { |
|
| 414 | + public function newComment() { |
|
| 415 | 415 | return $this->factory(Story::class, [ |
| 416 | 416 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED, |
| 417 | 417 | 'target' => $this |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @depends after-create |
| 425 | 425 | * @return Task |
| 426 | 426 | */ |
| 427 | - public function newSubTask () { |
|
| 427 | + public function newSubTask() { |
|
| 428 | 428 | /** @var Task $sub */ |
| 429 | 429 | $sub = $this->factory(self::class); |
| 430 | 430 | return $sub->setParent($this); |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * @param Task[] $tasks |
| 438 | 438 | * @return $this |
| 439 | 439 | */ |
| 440 | - public function removeDependencies (array $tasks) { |
|
| 440 | + public function removeDependencies(array $tasks) { |
|
| 441 | 441 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
| 442 | 442 | return $this; |
| 443 | 443 | } |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param Task $task |
| 450 | 450 | * @return $this |
| 451 | 451 | */ |
| 452 | - public function removeDependency (Task $task) { |
|
| 452 | + public function removeDependency(Task $task) { |
|
| 453 | 453 | return $this->removeDependencies([$task]); |
| 454 | 454 | } |
| 455 | 455 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @param Task $task |
| 461 | 461 | * @return $this |
| 462 | 462 | */ |
| 463 | - public function removeDependent (Task $task) { |
|
| 463 | + public function removeDependent(Task $task) { |
|
| 464 | 464 | return $this->removeDependents([$task]); |
| 465 | 465 | } |
| 466 | 466 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @param Task[] $tasks |
| 472 | 472 | * @return $this |
| 473 | 473 | */ |
| 474 | - public function removeDependents (array $tasks) { |
|
| 474 | + public function removeDependents(array $tasks) { |
|
| 475 | 475 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 476 | 476 | return $this; |
| 477 | 477 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @param User $user |
| 483 | 483 | * @return $this |
| 484 | 484 | */ |
| 485 | - public function removeFollower (User $user) { |
|
| 485 | + public function removeFollower(User $user) { |
|
| 486 | 486 | return $this->removeFollowers([$user]); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * @param User[] $users |
| 495 | 495 | * @return $this |
| 496 | 496 | */ |
| 497 | - public function removeFollowers (array $users) { |
|
| 497 | + public function removeFollowers(array $users) { |
|
| 498 | 498 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
| 499 | 499 | 'followers' => array_column($users, 'gid') |
| 500 | 500 | ], 'followers', $users); |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @param Project $project |
| 509 | 509 | * @return $this |
| 510 | 510 | */ |
| 511 | - public function removeFromProject (Project $project) { |
|
| 511 | + public function removeFromProject(Project $project) { |
|
| 512 | 512 | return $this->_removeWithPost("{$this}/removeProject", [ |
| 513 | 513 | 'project' => $project->getGid() |
| 514 | 514 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param Tag $tag |
| 525 | 525 | * @return $this |
| 526 | 526 | */ |
| 527 | - public function removeTag (Tag $tag) { |
|
| 527 | + public function removeTag(Tag $tag) { |
|
| 528 | 528 | return $this->_removeWithPost("{$this}/removeTag", [ |
| 529 | 529 | 'tag' => $tag->getGid() |
| 530 | 530 | ], 'tags', [$tag]); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | * @param callable $filter `fn( Attachment $attachment): bool` |
| 535 | 535 | * @return Attachment[] |
| 536 | 536 | */ |
| 537 | - public function selectAttachments (callable $filter) { |
|
| 537 | + public function selectAttachments(callable $filter) { |
|
| 538 | 538 | return $this->_select($this->getAttachments(), $filter); |
| 539 | 539 | } |
| 540 | 540 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | * @param callable $filter `fn( Story $comment ): bool` |
| 543 | 543 | * @return Story[] |
| 544 | 544 | */ |
| 545 | - public function selectComments (callable $filter) { |
|
| 545 | + public function selectComments(callable $filter) { |
|
| 546 | 546 | return $this->_select($this->getComments(), $filter); |
| 547 | 547 | } |
| 548 | 548 | |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param callable $filter `fn( Task $dependency ): bool` |
| 551 | 551 | * @return Task[] |
| 552 | 552 | */ |
| 553 | - public function selectDependencies (callable $filter) { |
|
| 553 | + public function selectDependencies(callable $filter) { |
|
| 554 | 554 | return $this->_select($this->getDependencies(), $filter); |
| 555 | 555 | } |
| 556 | 556 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @param callable $filter `fn( Task $dependent ): bool` |
| 559 | 559 | * @return Task[] |
| 560 | 560 | */ |
| 561 | - public function selectDependents (callable $filter) { |
|
| 561 | + public function selectDependents(callable $filter) { |
|
| 562 | 562 | return $this->_select($this->getDependents(), $filter); |
| 563 | 563 | } |
| 564 | 564 | |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param callable $filter `fn( Project $project ): bool` |
| 567 | 567 | * @return Project[] |
| 568 | 568 | */ |
| 569 | - public function selectProjects (callable $filter) { |
|
| 569 | + public function selectProjects(callable $filter) { |
|
| 570 | 570 | return $this->_select($this->getProjects(), $filter); |
| 571 | 571 | } |
| 572 | 572 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @param callable $filter `fn( Story $story ): bool` |
| 575 | 575 | * @return Story[] |
| 576 | 576 | */ |
| 577 | - public function selectStories (callable $filter) { |
|
| 577 | + public function selectStories(callable $filter) { |
|
| 578 | 578 | return $this->_select($this->getStories(), $filter); |
| 579 | 579 | } |
| 580 | 580 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @param callable $filter `fn( Task $subtask ): bool` |
| 583 | 583 | * @return Task[] |
| 584 | 584 | */ |
| 585 | - public function selectSubTasks (callable $filter) { |
|
| 585 | + public function selectSubTasks(callable $filter) { |
|
| 586 | 586 | return $this->_select($this->getSubTasks(), $filter); |
| 587 | 587 | } |
| 588 | 588 | |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @param null|Task $parent |
| 594 | 594 | * @return $this |
| 595 | 595 | */ |
| 596 | - public function setParent (?self $parent) { |
|
| 596 | + public function setParent(?self $parent) { |
|
| 597 | 597 | return $this->_setWithPost("{$this}/setParent", [ |
| 598 | 598 | 'parent' => $parent |
| 599 | 599 | ], 'parent', $parent); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | * @param bool $flag |
| 604 | 604 | * @return $this |
| 605 | 605 | */ |
| 606 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 606 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 607 | 607 | return $this->_set('is_rendered_as_separator', $flag); |
| 608 | 608 | } |
| 609 | 609 | |
@@ -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 |
@@ -44,45 +44,45 @@ discard block |
||
| 44 | 44 | 'target' => Task::class |
| 45 | 45 | ]; |
| 46 | 46 | |
| 47 | - final public function __toString (): string { |
|
| 47 | + final public function __toString(): string { |
|
| 48 | 48 | return "stories/{$this->getGid()}"; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - final protected function _getDir (): string { |
|
| 51 | + final protected function _getDir(): string { |
|
| 52 | 52 | return "{$this->getTarget()}/stories"; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _setData (array $data): void { |
|
| 55 | + protected function _setData(array $data): void { |
|
| 56 | 56 | // hearts are deprecated in favor of likes |
| 57 | 57 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 58 | 58 | parent::_setData($data); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - final public function isAssignment (): bool { |
|
| 61 | + final public function isAssignment(): bool { |
|
| 62 | 62 | return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - final public function isComment (): bool { |
|
| 65 | + final public function isComment(): bool { |
|
| 66 | 66 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - final public function isDueDate (): bool { |
|
| 69 | + final public function isDueDate(): bool { |
|
| 70 | 70 | return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function isEdited (): bool { |
|
| 73 | + public function isEdited(): bool { |
|
| 74 | 74 | return $this->_is('is_edited'); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function isFromApi (): bool { |
|
| 77 | + public function isFromApi(): bool { |
|
| 78 | 78 | return $this->getSource() === 'api'; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function isFromWeb (): bool { |
|
| 81 | + public function isFromWeb(): bool { |
|
| 82 | 82 | return $this->getSource() === 'web'; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function isPinned (): bool { |
|
| 85 | + public function isPinned(): bool { |
|
| 86 | 86 | return $this->_is('is_pinned'); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param bool $pinned |
| 91 | 91 | * @return $this |
| 92 | 92 | */ |
| 93 | - public function setPinned (bool $pinned) { |
|
| 93 | + public function setPinned(bool $pinned) { |
|
| 94 | 94 | return $this->_set('is_pinned', $pinned); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected $types = []; |
| 47 | 47 | |
| 48 | - public function __construct (Task $task, array $data = []) { |
|
| 48 | + public function __construct(Task $task, array $data = []) { |
|
| 49 | 49 | $this->task = $task; |
| 50 | 50 | parent::__construct($task, $data); |
| 51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param array $data |
| 57 | 57 | */ |
| 58 | - protected function _setData (array $data): void { |
|
| 58 | + protected function _setData(array $data): void { |
|
| 59 | 59 | $this->index = []; |
| 60 | 60 | $this->optionNames = []; |
| 61 | 61 | $keys = array_flip(['gid', 'name', 'type', 'enum_options', 'enum_value', 'text_value', 'number_value']); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @return int |
| 79 | 79 | */ |
| 80 | - public function count () { |
|
| 80 | + public function count() { |
|
| 81 | 81 | return count($this->data); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | * @param string $enumGid |
| 86 | 86 | * @return null|string |
| 87 | 87 | */ |
| 88 | - public function getCurrentOptionName (string $enumGid): ?string { |
|
| 88 | + public function getCurrentOptionName(string $enumGid): ?string { |
|
| 89 | 89 | return $this->getOptionName($enumGid, $this[$enumGid]); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function getDiff (): array { |
|
| 92 | + public function getDiff(): array { |
|
| 93 | 93 | $diff = []; |
| 94 | 94 | foreach (array_keys($this->diff) as $index) { |
| 95 | 95 | $gid = $this->index[$index]; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * @return Generator |
| 103 | 103 | */ |
| 104 | - public function getIterator () { |
|
| 104 | + public function getIterator() { |
|
| 105 | 105 | foreach (array_keys($this->index) as $gid) { |
| 106 | 106 | yield $gid => $this[$gid]; |
| 107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $fieldGid |
| 112 | 112 | * @return null|string |
| 113 | 113 | */ |
| 114 | - public function getName (string $fieldGid): ?string { |
|
| 114 | + public function getName(string $fieldGid): ?string { |
|
| 115 | 115 | return $this->data[$this->index[$fieldGid]]['name']; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string[] |
| 122 | 122 | */ |
| 123 | - public function getNames () { |
|
| 123 | + public function getNames() { |
|
| 124 | 124 | return array_column($this->data, 'name', 'gid'); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param string $optionGid |
| 130 | 130 | * @return null|string |
| 131 | 131 | */ |
| 132 | - public function getOptionName (string $enumGid, string $optionGid): ?string { |
|
| 132 | + public function getOptionName(string $enumGid, string $optionGid): ?string { |
|
| 133 | 133 | return $this->optionNames[$enumGid][$optionGid]; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $enumGid |
| 140 | 140 | * @return string[] |
| 141 | 141 | */ |
| 142 | - public function getOptionNames (string $enumGid) { |
|
| 142 | + public function getOptionNames(string $enumGid) { |
|
| 143 | 143 | return $this->optionNames[$enumGid]; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $fieldGid |
| 148 | 148 | * @return null|number|string |
| 149 | 149 | */ |
| 150 | - public function getValue (string $fieldGid) { |
|
| 150 | + public function getValue(string $fieldGid) { |
|
| 151 | 151 | $field = $this->data[$this->index[$fieldGid]]; |
| 152 | 152 | if ($field['type'] === CustomField::TYPE_ENUM) { |
| 153 | 153 | return $field['enum_value']['gid']; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param string $fieldGid |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function offsetExists ($fieldGid) { |
|
| 162 | + public function offsetExists($fieldGid) { |
|
| 163 | 163 | return array_key_exists($this->index[$fieldGid], $this->data); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param string $fieldGid |
| 168 | 168 | * @return null|number|string |
| 169 | 169 | */ |
| 170 | - public function offsetGet ($fieldGid) { |
|
| 170 | + public function offsetGet($fieldGid) { |
|
| 171 | 171 | return $this->getValue($fieldGid); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param string $fieldGid |
| 176 | 176 | * @param null|number|string $value |
| 177 | 177 | */ |
| 178 | - public function offsetSet ($fieldGid, $value) { |
|
| 178 | + public function offsetSet($fieldGid, $value) { |
|
| 179 | 179 | $this->setValue($fieldGid, $value); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @param string $fieldGid |
| 186 | 186 | */ |
| 187 | - public function offsetUnset ($fieldGid) { |
|
| 187 | + public function offsetUnset($fieldGid) { |
|
| 188 | 188 | $this->setValue($fieldGid, null); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param null|number|string $value |
| 194 | 194 | * @return $this |
| 195 | 195 | */ |
| 196 | - public function setValue (string $fieldGid, $value) { |
|
| 196 | + public function setValue(string $fieldGid, $value) { |
|
| 197 | 197 | $i = $this->index[$fieldGid]; |
| 198 | 198 | $type = $this->data[$i]['type']; |
| 199 | 199 | if ($type === CustomField::TYPE_ENUM) { |
@@ -198,8 +198,7 @@ |
||
| 198 | 198 | $type = $this->data[$i]['type']; |
| 199 | 199 | if ($type === CustomField::TYPE_ENUM) { |
| 200 | 200 | $this->data[$i]['enum_value']['gid'] = $value; |
| 201 | - } |
|
| 202 | - else { |
|
| 201 | + } else { |
|
| 203 | 202 | $this->data["{$type}_value"] = $value; |
| 204 | 203 | } |
| 205 | 204 | $this->diff[$i] = true; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | const TYPE = 'workspace'; |
| 29 | 29 | |
| 30 | - final public function __toString (): string { |
|
| 30 | + final public function __toString(): string { |
|
| 31 | 31 | return "workspaces/{$this->getGid()}"; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return OrganizationExport |
| 38 | 38 | */ |
| 39 | - public function export () { |
|
| 39 | + public function export() { |
|
| 40 | 40 | /** @var OrganizationExport $export */ |
| 41 | 41 | $export = $this->factory(OrganizationExport::class); |
| 42 | 42 | return $export->create($this); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param int $limit 1-100 |
| 57 | 57 | * @return array|AbstractEntity[] |
| 58 | 58 | */ |
| 59 | - protected function find (string $class, string $text, int $limit = 20) { |
|
| 59 | + protected function find(string $class, string $text, int $limit = 20) { |
|
| 60 | 60 | return $this->loadAll($class, "{$this}/typeahead", [ |
| 61 | 61 | 'resource_type' => $class::TYPE, |
| 62 | 62 | 'query' => $text, |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param int $limit 1-100 |
| 72 | 72 | * @return CustomField[] |
| 73 | 73 | */ |
| 74 | - public function findCustomFields (string $text, int $limit = 20) { |
|
| 74 | + public function findCustomFields(string $text, int $limit = 20) { |
|
| 75 | 75 | return $this->find(CustomField::class, $text, $limit); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param int $limit 1-100 |
| 83 | 83 | * @return Portfolio[] |
| 84 | 84 | */ |
| 85 | - public function findPortfolios (string $text, int $limit = 20) { |
|
| 85 | + public function findPortfolios(string $text, int $limit = 20) { |
|
| 86 | 86 | return $this->find(Portfolio::class, $text, $limit); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param int $limit 1-100 |
| 94 | 94 | * @return Project[] |
| 95 | 95 | */ |
| 96 | - public function findProjects (string $text, int $limit = 20) { |
|
| 96 | + public function findProjects(string $text, int $limit = 20) { |
|
| 97 | 97 | return $this->find(Project::class, $text, $limit); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param int $limit 1-100 |
| 105 | 105 | * @return Tag[] |
| 106 | 106 | */ |
| 107 | - public function findTags (string $text, int $limit = 20) { |
|
| 107 | + public function findTags(string $text, int $limit = 20) { |
|
| 108 | 108 | return $this->find(Tag::class, $text, $limit); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | * @param int $limit 1-100 |
| 116 | 116 | * @return Task[] |
| 117 | 117 | */ |
| 118 | - public function findTasks (string $text, int $limit = 20) { |
|
| 118 | + public function findTasks(string $text, int $limit = 20) { |
|
| 119 | 119 | return $this->find(Task::class, $text, $limit); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * @return CustomField[] |
| 124 | 124 | */ |
| 125 | - public function getCustomFields () { |
|
| 125 | + public function getCustomFields() { |
|
| 126 | 126 | return $this->loadAll(CustomField::class, "{$this}/custom_fields"); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return Portfolio[] |
| 135 | 135 | */ |
| 136 | - public function getPortfolios () { |
|
| 136 | + public function getPortfolios() { |
|
| 137 | 137 | return $this->loadAll(Portfolio::class, "portfolios", [ |
| 138 | 138 | 'workspace' => $this->getGid(), |
| 139 | 139 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param array $filter |
| 149 | 149 | * @return Project[] |
| 150 | 150 | */ |
| 151 | - public function getProjects (array $filter = ['archived' => false]) { |
|
| 151 | + public function getProjects(array $filter = ['archived' => false]) { |
|
| 152 | 152 | $filter['workspace'] = $this->getGid(); |
| 153 | 153 | return $this->loadAll(Project::class, 'projects', $filter); |
| 154 | 154 | } |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | /** |
| 157 | 157 | * @return Tag[] |
| 158 | 158 | */ |
| 159 | - public function getTags () { |
|
| 159 | + public function getTags() { |
|
| 160 | 160 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * @return Team[] |
| 165 | 165 | */ |
| 166 | - public function getTeams () { |
|
| 166 | + public function getTeams() { |
|
| 167 | 167 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $email |
| 172 | 172 | * @return null|User |
| 173 | 173 | */ |
| 174 | - public function getUserByEmail (string $email) { |
|
| 174 | + public function getUserByEmail(string $email) { |
|
| 175 | 175 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
| 176 | 176 | foreach ($this->getUsers() as $user) { |
| 177 | 177 | if ($user->getEmail() === $email) { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | /** |
| 186 | 186 | * @return User[] |
| 187 | 187 | */ |
| 188 | - public function getUsers () { |
|
| 188 | + public function getUsers() { |
|
| 189 | 189 | return $this->loadAll(User::class, "{$this}/users"); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return ProjectWebhook[]|TaskWebhook[] |
| 196 | 196 | */ |
| 197 | - public function getWebhooks () { |
|
| 197 | + public function getWebhooks() { |
|
| 198 | 198 | /** @var array $all */ |
| 199 | 199 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 200 | 200 | return array_map(function(array $each) { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * @return bool |
| 213 | 213 | */ |
| 214 | - public function isOrganization (): bool { |
|
| 214 | + public function isOrganization(): bool { |
|
| 215 | 215 | return $this->_is('is_organization'); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return CustomField |
| 222 | 222 | */ |
| 223 | - public function newCustomField () { |
|
| 223 | + public function newCustomField() { |
|
| 224 | 224 | /** @var CustomField $field */ |
| 225 | 225 | $field = $this->factory(CustomField::class); |
| 226 | 226 | return $field->setWorkspace($this); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return Portfolio |
| 233 | 233 | */ |
| 234 | - public function newPortfolio () { |
|
| 234 | + public function newPortfolio() { |
|
| 235 | 235 | /** @var Portfolio $portfolio */ |
| 236 | 236 | $portfolio = $this->factory(Portfolio::class); |
| 237 | 237 | return $portfolio->setWorkspace($this); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return Project |
| 244 | 244 | */ |
| 245 | - public function newProject () { |
|
| 245 | + public function newProject() { |
|
| 246 | 246 | /** @var Project $project */ |
| 247 | 247 | $project = $this->factory(Project::class); |
| 248 | 248 | return $project->setWorkspace($this); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return Tag |
| 255 | 255 | */ |
| 256 | - public function newTag () { |
|
| 256 | + public function newTag() { |
|
| 257 | 257 | /** @var Tag $tag */ |
| 258 | 258 | $tag = $this->factory(Tag::class); |
| 259 | 259 | return $tag->setWorkspace($this); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return Task |
| 266 | 266 | */ |
| 267 | - public function newTask () { |
|
| 267 | + public function newTask() { |
|
| 268 | 268 | /** @var Task $task */ |
| 269 | 269 | $task = $this->factory(Task::class); |
| 270 | 270 | return $task->setWorkspace($this); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @param callable $filter `fn( CustomField $field ): bool` |
| 275 | 275 | * @return CustomField[] |
| 276 | 276 | */ |
| 277 | - public function selectCustomFields (callable $filter) { |
|
| 277 | + public function selectCustomFields(callable $filter) { |
|
| 278 | 278 | return $this->_select($this->getCustomFields(), $filter); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
| 283 | 283 | * @return Portfolio[] |
| 284 | 284 | */ |
| 285 | - public function selectPortfolios (callable $filter) { |
|
| 285 | + public function selectPortfolios(callable $filter) { |
|
| 286 | 286 | return $this->_select($this->getPortfolios(), $filter); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param callable $filter `fn( Project $project ): bool` |
| 291 | 291 | * @return Project[] |
| 292 | 292 | */ |
| 293 | - public function selectProjects (callable $filter) { |
|
| 293 | + public function selectProjects(callable $filter) { |
|
| 294 | 294 | return $this->_select($this->getProjects([]), $filter); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @param callable $filter `fn( Tag $tag ): bool` |
| 299 | 299 | * @return Tag[] |
| 300 | 300 | */ |
| 301 | - public function selectTags (callable $filter) { |
|
| 301 | + public function selectTags(callable $filter) { |
|
| 302 | 302 | return $this->_select($this->getTags(), $filter); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param callable $filter `fn( Team $team ): bool` |
| 307 | 307 | * @return Team[] |
| 308 | 308 | */ |
| 309 | - public function selectTeams (callable $filter) { |
|
| 309 | + public function selectTeams(callable $filter) { |
|
| 310 | 310 | return $this->_select($this->getTeams(), $filter); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @param callable $filter |
| 315 | 315 | * @return User[] |
| 316 | 316 | */ |
| 317 | - public function selectUsers (callable $filter) { |
|
| 317 | + public function selectUsers(callable $filter) { |
|
| 318 | 318 | return $this->_select($this->getUsers(), $filter); |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | \ No newline at end of file |