@@ -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() */ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param array $filter |
| 48 | 48 | * @return Traversable|Task[] |
| 49 | 49 | */ |
| 50 | - public function getIterator (array $filter = []) { |
|
| 50 | + public function getIterator(array $filter = []) { |
|
| 51 | 51 | return $this->api->loadEach($this, Task::class, "{$this}/tasks"); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param array $filter |
| 60 | 60 | * @return Task[] |
| 61 | 61 | */ |
| 62 | - public function getTasks (array $filter = []) { |
|
| 62 | + public function getTasks(array $filter = []) { |
|
| 63 | 63 | return iterator_to_array($this->getIterator($filter)); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param array $apiFilter Given to the API to reduce network load. |
| 69 | 69 | * @return Task[] |
| 70 | 70 | */ |
| 71 | - public function selectTasks (callable $filter, array $apiFilter) { |
|
| 71 | + public function selectTasks(callable $filter, array $apiFilter) { |
|
| 72 | 72 | return $this->_select($this->getIterator($apiFilter), $filter); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | \ 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->api->loadAll($this, $class, "{$this}/favorites", [ |
| 117 | 117 | 'resource_type' => $resourceType, |
| 118 | 118 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param null|Workspace $workspace |
| 124 | 124 | * @return Portfolio[] |
| 125 | 125 | */ |
| 126 | - public function getPortfolios (Workspace $workspace = null) { |
|
| 126 | + public function getPortfolios(Workspace $workspace = null) { |
|
| 127 | 127 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
| 128 | 128 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid(), |
| 129 | 129 | 'owner' => $this->getGid() |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 135 | 135 | * @return TaskList |
| 136 | 136 | */ |
| 137 | - public function getTaskList (Workspace $workspace = null) { |
|
| 137 | + public function getTaskList(Workspace $workspace = null) { |
|
| 138 | 138 | return $this->api->load($this, TaskList::class, "{$this}/user_task_list", [ |
| 139 | 139 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
| 140 | 140 | ]); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param string[] $filter `workspace` falls back to the default. |
| 147 | 147 | * @return Task[] |
| 148 | 148 | */ |
| 149 | - public function getTasks (array $filter = []) { |
|
| 149 | + public function getTasks(array $filter = []) { |
|
| 150 | 150 | $filter['assignee'] = $this->getGid(); |
| 151 | 151 | $filter += ['workspace' => $this->getDefaultWorkspace()->getGid()]; |
| 152 | 152 | return $this->api->loadAll($this, Task::class, 'tasks', $filter); |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | * @param null|Workspace $organization Falls back to the default workspace. |
| 161 | 161 | * @return Team[] |
| 162 | 162 | */ |
| 163 | - public function getTeams (Workspace $organization = null) { |
|
| 163 | + public function getTeams(Workspace $organization = null) { |
|
| 164 | 164 | return $this->api->loadAll($this, Team::class, "{$this}/teams", [ |
| 165 | 165 | 'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid() |
| 166 | 166 | ]); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function getUrl (): string { |
|
| 169 | + public function getUrl(): string { |
|
| 170 | 170 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param Workspace $workspace |
| 175 | 175 | * @return $this |
| 176 | 176 | */ |
| 177 | - public function removeFromWorkspace (Workspace $workspace) { |
|
| 177 | + public function removeFromWorkspace(Workspace $workspace) { |
|
| 178 | 178 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
| 179 | 179 | 'user' => $this->getGid() |
| 180 | 180 | ], 'workspaces', [$workspace]); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | 'workspace' => Workspace::class |
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - final public function __toString (): string { |
|
| 55 | + final public function __toString(): string { |
|
| 56 | 56 | return "portfolios/{$this->getGid()}"; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - final protected function _getDir (): string { |
|
| 59 | + final protected function _getDir(): string { |
|
| 60 | 60 | return 'portfolios'; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param Project $item |
| 66 | 66 | * @return $this |
| 67 | 67 | */ |
| 68 | - public function addItem (Project $item) { |
|
| 68 | + public function addItem(Project $item) { |
|
| 69 | 69 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
| 70 | 70 | return $this; |
| 71 | 71 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param User $user |
| 75 | 75 | * @return $this |
| 76 | 76 | */ |
| 77 | - public function addMember (User $user) { |
|
| 77 | + public function addMember(User $user) { |
|
| 78 | 78 | return $this->addMembers([$user]); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param User[] $users |
| 83 | 83 | * @return $this |
| 84 | 84 | */ |
| 85 | - public function addMembers (array $users) { |
|
| 85 | + public function addMembers(array $users) { |
|
| 86 | 86 | return $this->_addWithPost("{$this}/addMembers", [ |
| 87 | 87 | 'members' => array_column($users, 'gid') |
| 88 | 88 | ], 'members', $users); |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | * @depends after-create |
| 93 | 93 | * @return Project[] |
| 94 | 94 | */ |
| 95 | - public function getItems () { |
|
| 95 | + public function getItems() { |
|
| 96 | 96 | return iterator_to_array($this); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @return Traversable|Project[] |
| 101 | 101 | */ |
| 102 | - public function getIterator () { |
|
| 102 | + public function getIterator() { |
|
| 103 | 103 | return $this->api->loadEach($this, Project::class, "{$this}/items"); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param Project $item |
| 109 | 109 | * @return $this |
| 110 | 110 | */ |
| 111 | - public function removeItem (Project $item) { |
|
| 111 | + public function removeItem(Project $item) { |
|
| 112 | 112 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
| 113 | 113 | return $this; |
| 114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param User $user |
| 118 | 118 | * @return $this |
| 119 | 119 | */ |
| 120 | - public function removeMember (User $user) { |
|
| 120 | + public function removeMember(User $user) { |
|
| 121 | 121 | return $this->removeMembers([$user]); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param User[] $users |
| 126 | 126 | * @return $this |
| 127 | 127 | */ |
| 128 | - public function removeMembers (array $users) { |
|
| 128 | + public function removeMembers(array $users) { |
|
| 129 | 129 | return $this->_removeWithPost("{$this}/removeMembers", [ |
| 130 | 130 | 'members' => array_column($users, 'gid') |
| 131 | 131 | ], 'members', $users); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param callable $filter `fn( Project $project ): bool` |
| 136 | 136 | * @return Project[] |
| 137 | 137 | */ |
| 138 | - public function selectItems (callable $filter) { |
|
| 138 | + public function selectItems(callable $filter) { |
|
| 139 | 139 | return $this->_select($this, $filter); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param Api|Data $caller |
| 59 | 59 | * @param array $data |
| 60 | 60 | */ |
| 61 | - public function __construct ($caller, array $data = []) { |
|
| 61 | + public function __construct($caller, array $data = []) { |
|
| 62 | 62 | $this->api = $caller instanceof self ? $caller->api : $caller; |
| 63 | 63 | $this->_setData($data); |
| 64 | 64 | } |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @param array $args |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - public function __call (string $method, array $args) { |
|
| 77 | + public function __call(string $method, array $args) { |
|
| 78 | 78 | static $cache = []; |
| 79 | - if (!$call =& $cache[$method]) { |
|
| 79 | + if (!$call = & $cache[$method]) { |
|
| 80 | 80 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
| 81 | 81 | $call[1] = '_' . $call[1]; |
| 82 | 82 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | return $this->{$call[1]}($call[2], ...$args); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function __debugInfo (): array { |
|
| 89 | + public function __debugInfo(): array { |
|
| 90 | 90 | return $this->data; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param $field |
| 97 | 97 | * @return null|Data|mixed |
| 98 | 98 | */ |
| 99 | - final public function __get ($field) { |
|
| 99 | + final public function __get($field) { |
|
| 100 | 100 | return $this->_get($field); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param $field |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - final public function __isset ($field) { |
|
| 111 | + final public function __isset($field) { |
|
| 112 | 112 | return true; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param array $data |
| 120 | 120 | * @return mixed|Data|AbstractEntity |
| 121 | 121 | */ |
| 122 | - final protected function _factory (string $class, array $data = []) { |
|
| 122 | + final protected function _factory(string $class, array $data = []) { |
|
| 123 | 123 | return $this->api->factory($class, $this, $data); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $field |
| 132 | 132 | * @return mixed |
| 133 | 133 | */ |
| 134 | - protected function _get (string $field) { |
|
| 134 | + protected function _get(string $field) { |
|
| 135 | 135 | return $this->data[$field] ?? null; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param string $field |
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | - protected function _has (string $field): bool { |
|
| 149 | + protected function _has(string $field): bool { |
|
| 150 | 150 | $value = $this->_get($field); |
| 151 | 151 | if (isset($value)) { |
| 152 | 152 | if (is_countable($value)) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $field |
| 170 | 170 | * @return bool |
| 171 | 171 | */ |
| 172 | - protected function _is (string $field): bool { |
|
| 172 | + protected function _is(string $field): bool { |
|
| 173 | 173 | return (bool)$this->_get($field); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param callable $filter `fn( Data $object ): bool` |
| 185 | 185 | * @return array |
| 186 | 186 | */ |
| 187 | - protected function _select ($subject, callable $filter) { |
|
| 187 | + protected function _select($subject, callable $filter) { |
|
| 188 | 188 | if (!is_iterable($subject)) { |
| 189 | 189 | $subject = $this->_get($subject) ?? []; |
| 190 | 190 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param mixed $value |
| 207 | 207 | * @return $this |
| 208 | 208 | */ |
| 209 | - protected function _set (string $field, $value) { |
|
| 209 | + protected function _set(string $field, $value) { |
|
| 210 | 210 | $this->data[$field] = $value; |
| 211 | 211 | $this->diff[$field] = true; |
| 212 | 212 | return $this; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @param array $data |
| 219 | 219 | */ |
| 220 | - protected function _setData (array $data): void { |
|
| 220 | + protected function _setData(array $data): void { |
|
| 221 | 221 | $this->data = $this->diff = []; |
| 222 | 222 | foreach ($data as $field => $value) { |
| 223 | 223 | $this->_setMapped($field, $value); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param string $field |
| 231 | 231 | * @param mixed $value |
| 232 | 232 | */ |
| 233 | - protected function _setMapped (string $field, $value): void { |
|
| 233 | + protected function _setMapped(string $field, $value): void { |
|
| 234 | 234 | unset($this->diff[$field]); |
| 235 | 235 | |
| 236 | 236 | // use value as-is? |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return array |
| 284 | 284 | */ |
| 285 | - public function getDiff (): array { |
|
| 285 | + public function getDiff(): array { |
|
| 286 | 286 | $convert = function($each) use (&$convert) { |
| 287 | 287 | // convert existing entities to gids |
| 288 | 288 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param string null $field |
| 309 | 309 | * @return bool |
| 310 | 310 | */ |
| 311 | - final public function isDiff (string $field = null): bool { |
|
| 311 | + final public function isDiff(string $field = null): bool { |
|
| 312 | 312 | if ($field) { |
| 313 | 313 | return isset($this->diff[$field]); |
| 314 | 314 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @see toArray() |
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | - public function jsonSerialize (): array { |
|
| 322 | + public function jsonSerialize(): array { |
|
| 323 | 323 | $data = $this->toArray(); |
| 324 | 324 | ksort($data); |
| 325 | 325 | return $data; |
@@ -330,8 +330,8 @@ discard block |
||
| 330 | 330 | * |
| 331 | 331 | * @return string |
| 332 | 332 | */ |
| 333 | - public function serialize (): string { |
|
| 334 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
| 333 | + public function serialize(): string { |
|
| 334 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @return array |
| 341 | 341 | */ |
| 342 | - public function toArray (): array { |
|
| 342 | + public function toArray(): array { |
|
| 343 | 343 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
| 344 | 344 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
| 345 | 345 | return $each->getGid(); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @param $serialized |
| 361 | 361 | */ |
| 362 | - public function unserialize ($serialized): void { |
|
| 362 | + public function unserialize($serialized): void { |
|
| 363 | 363 | $this->api = Api::getDefault(); |
| 364 | 364 | $data = json_decode($serialized, true); |
| 365 | 365 | $this->_setData($data); |
@@ -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->api->loadAll($this, $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->api->loadAll($this, 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->api->loadAll($this, Portfolio::class, "portfolios", [ |
| 138 | 138 | 'workspace' => $this->getGid(), |
| 139 | 139 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param array $filter |
| 147 | 147 | * @return Project[] |
| 148 | 148 | */ |
| 149 | - public function getProjects (array $filter = Project::FILTER_ACTIVE) { |
|
| 149 | + public function getProjects(array $filter = Project::FILTER_ACTIVE) { |
|
| 150 | 150 | $filter['workspace'] = $this->getGid(); |
| 151 | 151 | return $this->api->loadAll($this, Project::class, 'projects', $filter); |
| 152 | 152 | } |
@@ -154,14 +154,14 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * @return Tag[] |
| 156 | 156 | */ |
| 157 | - public function getTags () { |
|
| 157 | + public function getTags() { |
|
| 158 | 158 | return $this->api->loadAll($this, Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * @return Team[] |
| 163 | 163 | */ |
| 164 | - public function getTeams () { |
|
| 164 | + public function getTeams() { |
|
| 165 | 165 | return $this->api->loadAll($this, Team::class, "organizations/{$this->getGid()}/teams"); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $email |
| 170 | 170 | * @return null|User |
| 171 | 171 | */ |
| 172 | - public function getUserByEmail (string $email) { |
|
| 172 | + public function getUserByEmail(string $email) { |
|
| 173 | 173 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
| 174 | 174 | foreach ($this->getUsers() as $user) { |
| 175 | 175 | if ($user->getEmail() === $email) { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | /** |
| 184 | 184 | * @return User[] |
| 185 | 185 | */ |
| 186 | - public function getUsers () { |
|
| 186 | + public function getUsers() { |
|
| 187 | 187 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @return ProjectWebhook[]|TaskWebhook[] |
| 194 | 194 | */ |
| 195 | - public function getWebhooks () { |
|
| 195 | + public function getWebhooks() { |
|
| 196 | 196 | /** @var array $all */ |
| 197 | 197 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 198 | 198 | return array_map(function(array $each) { |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | /** |
| 210 | 210 | * @return bool |
| 211 | 211 | */ |
| 212 | - public function isOrganization (): bool { |
|
| 212 | + public function isOrganization(): bool { |
|
| 213 | 213 | return $this->_is('is_organization'); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return CustomField |
| 220 | 220 | */ |
| 221 | - public function newCustomField () { |
|
| 221 | + public function newCustomField() { |
|
| 222 | 222 | /** @var CustomField $field */ |
| 223 | 223 | $field = $this->_factory(CustomField::class); |
| 224 | 224 | return $field->setWorkspace($this); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return Portfolio |
| 231 | 231 | */ |
| 232 | - public function newPortfolio () { |
|
| 232 | + public function newPortfolio() { |
|
| 233 | 233 | /** @var Portfolio $portfolio */ |
| 234 | 234 | $portfolio = $this->_factory(Portfolio::class); |
| 235 | 235 | return $portfolio->setWorkspace($this); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return Project |
| 242 | 242 | */ |
| 243 | - public function newProject () { |
|
| 243 | + public function newProject() { |
|
| 244 | 244 | /** @var Project $project */ |
| 245 | 245 | $project = $this->_factory(Project::class); |
| 246 | 246 | return $project->setWorkspace($this); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return Tag |
| 253 | 253 | */ |
| 254 | - public function newTag () { |
|
| 254 | + public function newTag() { |
|
| 255 | 255 | /** @var Tag $tag */ |
| 256 | 256 | $tag = $this->_factory(Tag::class); |
| 257 | 257 | return $tag->setWorkspace($this); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @return Task |
| 264 | 264 | */ |
| 265 | - public function newTask () { |
|
| 265 | + public function newTask() { |
|
| 266 | 266 | /** @var Task $task */ |
| 267 | 267 | $task = $this->_factory(Task::class); |
| 268 | 268 | return $task->setWorkspace($this); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param callable $filter `fn( CustomField $field ): bool` |
| 273 | 273 | * @return CustomField[] |
| 274 | 274 | */ |
| 275 | - public function selectCustomFields (callable $filter) { |
|
| 275 | + public function selectCustomFields(callable $filter) { |
|
| 276 | 276 | return $this->_select($this->getCustomFields(), $filter); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
| 281 | 281 | * @return Portfolio[] |
| 282 | 282 | */ |
| 283 | - public function selectPortfolios (callable $filter) { |
|
| 283 | + public function selectPortfolios(callable $filter) { |
|
| 284 | 284 | return $this->_select($this->getPortfolios(), $filter); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @param callable $filter `fn( Project $project ): bool` |
| 289 | 289 | * @return Project[] |
| 290 | 290 | */ |
| 291 | - public function selectProjects (callable $filter) { |
|
| 291 | + public function selectProjects(callable $filter) { |
|
| 292 | 292 | return $this->_select($this->getProjects([]), $filter); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param callable $filter `fn( Tag $tag ): bool` |
| 297 | 297 | * @return Tag[] |
| 298 | 298 | */ |
| 299 | - public function selectTags (callable $filter) { |
|
| 299 | + public function selectTags(callable $filter) { |
|
| 300 | 300 | return $this->_select($this->getTags(), $filter); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param callable $filter `fn( Team $team ): bool` |
| 305 | 305 | * @return Team[] |
| 306 | 306 | */ |
| 307 | - public function selectTeams (callable $filter) { |
|
| 307 | + public function selectTeams(callable $filter) { |
|
| 308 | 308 | return $this->_select($this->getTeams(), $filter); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @param callable $filter |
| 313 | 313 | * @return User[] |
| 314 | 314 | */ |
| 315 | - public function selectUsers (callable $filter) { |
|
| 315 | + public function selectUsers(callable $filter) { |
|
| 316 | 316 | return $this->_select($this->getUsers(), $filter); |
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | \ No newline at end of file |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | 'workspace' => Workspace::class |
| 73 | 73 | ]; |
| 74 | 74 | |
| 75 | - final public function __toString (): string { |
|
| 75 | + final public function __toString(): string { |
|
| 76 | 76 | return "projects/{$this->getGid()}"; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - final protected function _getDir (): string { |
|
| 79 | + final protected function _getDir(): string { |
|
| 80 | 80 | return 'projects'; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - protected function _setData (array $data): void { |
|
| 83 | + protected function _setData(array $data): void { |
|
| 84 | 84 | // this is always empty. fields are in the settings, values are in tasks. |
| 85 | 85 | unset($data['custom_fields']); |
| 86 | 86 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param User $user |
| 96 | 96 | * @return $this |
| 97 | 97 | */ |
| 98 | - public function addMember (User $user) { |
|
| 98 | + public function addMember(User $user) { |
|
| 99 | 99 | return $this->addMembers([$user]); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param User[] $users |
| 105 | 105 | * @return $this |
| 106 | 106 | */ |
| 107 | - public function addMembers (array $users) { |
|
| 107 | + public function addMembers(array $users) { |
|
| 108 | 108 | return $this->_addWithPost("{$this}/addMembers", [ |
| 109 | 109 | 'members' => array_column($users, 'gid') |
| 110 | 110 | ], 'members', $users); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $target |
| 116 | 116 | * @return ProjectWebhook |
| 117 | 117 | */ |
| 118 | - public function addWebhook (string $target) { |
|
| 118 | + public function addWebhook(string $target) { |
|
| 119 | 119 | /** @var ProjectWebhook $webhook */ |
| 120 | 120 | $webhook = $this->_factory(ProjectWebhook::class); |
| 121 | 121 | return $webhook->create($this, $target); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param array $schedule |
| 141 | 141 | * @return Job |
| 142 | 142 | */ |
| 143 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
| 143 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
| 144 | 144 | $data = ['name' => $name]; |
| 145 | 145 | if ($team) { |
| 146 | 146 | $data['team'] = $team->getGid(); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @depends after-create |
| 160 | 160 | * @return Section |
| 161 | 161 | */ |
| 162 | - public function getDefaultSection () { |
|
| 162 | + public function getDefaultSection() { |
|
| 163 | 163 | return $this->api->loadAll($this, Section::class, "{$this}/sections", ['limit' => 1])[0]; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -170,14 +170,14 @@ discard block |
||
| 170 | 170 | * @param null|string $token |
| 171 | 171 | * @return Event[] |
| 172 | 172 | */ |
| 173 | - public function getEvents (&$token) { |
|
| 173 | + public function getEvents(&$token) { |
|
| 174 | 174 | return $this->api->sync($this, $token); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * @return Traversable|Section[] |
| 179 | 179 | */ |
| 180 | - public function getIterator () { |
|
| 180 | + public function getIterator() { |
|
| 181 | 181 | return $this->api->loadEach($this, Section::class, "{$this}/sections"); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @depends after-create |
| 186 | 186 | * @return Section[] |
| 187 | 187 | */ |
| 188 | - public function getSections () { |
|
| 188 | + public function getSections() { |
|
| 189 | 189 | return iterator_to_array($this); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @depends after-create |
| 194 | 194 | * @return Status[] |
| 195 | 195 | */ |
| 196 | - public function getStatuses () { |
|
| 196 | + public function getStatuses() { |
|
| 197 | 197 | return $this->api->loadAll($this, Status::class, "{$this}/project_statuses"); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param array $filter |
| 205 | 205 | * @return Task[] |
| 206 | 206 | */ |
| 207 | - public function getTasks (array $filter = []) { |
|
| 207 | + public function getTasks(array $filter = []) { |
|
| 208 | 208 | $filter['project'] = $this->getGid(); |
| 209 | 209 | return $this->api->loadAll($this, Task::class, "tasks", $filter); |
| 210 | 210 | } |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | * @depends after-create |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | - public function getUrl (): string { |
|
| 216 | + public function getUrl(): string { |
|
| 217 | 217 | return "https://app.asana.com/0/{$this->getGid()}"; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * @return ProjectWebhook[] |
| 222 | 222 | */ |
| 223 | - public function getWebhooks () { |
|
| 223 | + public function getWebhooks() { |
|
| 224 | 224 | return $this->api->loadAll($this, ProjectWebhook::class, 'webhooks', [ |
| 225 | 225 | 'workspace' => $this->getWorkspace()->getGid(), |
| 226 | 226 | 'resource' => $this->getGid() |
| 227 | 227 | ]); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - public function isBoard (): bool { |
|
| 230 | + public function isBoard(): bool { |
|
| 231 | 231 | return $this->getLayout() === self::LAYOUT_BOARD; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - public function isList (): bool { |
|
| 234 | + public function isList(): bool { |
|
| 235 | 235 | return $this->getLayout() === self::LAYOUT_LIST; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @depends after-create |
| 240 | 240 | * @return Section |
| 241 | 241 | */ |
| 242 | - public function newSection () { |
|
| 242 | + public function newSection() { |
|
| 243 | 243 | return $this->_factory(Section::class, ['project' => $this]); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @depends after-create |
| 248 | 248 | * @return Status |
| 249 | 249 | */ |
| 250 | - public function newStatus () { |
|
| 250 | + public function newStatus() { |
|
| 251 | 251 | return $this->_factory(Status::class); |
| 252 | 252 | } |
| 253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @depends after-create |
| 258 | 258 | * @return Task |
| 259 | 259 | */ |
| 260 | - public function newTask () { |
|
| 260 | + public function newTask() { |
|
| 261 | 261 | return $this->getDefaultSection()->newTask(); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param User $user |
| 267 | 267 | * @return $this |
| 268 | 268 | */ |
| 269 | - public function removeMember (User $user) { |
|
| 269 | + public function removeMember(User $user) { |
|
| 270 | 270 | return $this->removeMembers([$user]); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param User[] $users |
| 276 | 276 | * @return $this |
| 277 | 277 | */ |
| 278 | - public function removeMembers (array $users) { |
|
| 278 | + public function removeMembers(array $users) { |
|
| 279 | 279 | return $this->_removeWithPost("{$this}/removeMembers", [ |
| 280 | 280 | 'members' => array_column($users, 'gid') |
| 281 | 281 | ], 'members', $users); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param callable $filter `fn( Section $section ): bool` |
| 286 | 286 | * @return Section[] |
| 287 | 287 | */ |
| 288 | - public function selectSections (callable $filter) { |
|
| 288 | + public function selectSections(callable $filter) { |
|
| 289 | 289 | return $this->_select($this->getSections(), $filter); |
| 290 | 290 | } |
| 291 | 291 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param callable $filter `fn( Status $status ): bool` |
| 294 | 294 | * @return Status[] |
| 295 | 295 | */ |
| 296 | - public function selectStatuses (callable $filter) { |
|
| 296 | + public function selectStatuses(callable $filter) { |
|
| 297 | 297 | return $this->_select($this->getStatuses(), $filter); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param array $apiFilter Pre-filter given to the API to reduce network load. |
| 303 | 303 | * @return Task[] |
| 304 | 304 | */ |
| 305 | - public function selectTasks (callable $filter, array $apiFilter = []) { |
|
| 305 | + public function selectTasks(callable $filter, array $apiFilter = []) { |
|
| 306 | 306 | return $this->_select($this->getTasks($apiFilter), $filter); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param null|Team $team |
| 312 | 312 | * @return $this |
| 313 | 313 | */ |
| 314 | - public function setTeam (?Team $team) { |
|
| 314 | + public function setTeam(?Team $team) { |
|
| 315 | 315 | if ($team and !$this->hasWorkspace()) { |
| 316 | 316 | $this->setWorkspace($team->getOrganization()); |
| 317 | 317 | } |
@@ -53,25 +53,25 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return Cache |
| 55 | 55 | */ |
| 56 | - public static function getCache () { |
|
| 56 | + public static function getCache() { |
|
| 57 | 57 | return static::$cache ?? static::$cache = new Cache(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @return Api |
| 62 | 62 | */ |
| 63 | - public static function getDefault () { |
|
| 63 | + public static function getDefault() { |
|
| 64 | 64 | return self::$default; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * @return LoggerInterface |
| 69 | 69 | */ |
| 70 | - public static function getLogger () { |
|
| 70 | + public static function getLogger() { |
|
| 71 | 71 | return static::$logger |
| 72 | 72 | ?? static::$logger = new class implements LoggerInterface { |
| 73 | 73 | |
| 74 | - public function log (string $message, string $path, array $data = null): void { |
|
| 74 | + public function log(string $message, string $path, array $data = null): void { |
|
| 75 | 75 | // stub |
| 76 | 76 | } |
| 77 | 77 | |
@@ -81,28 +81,28 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @param Cache $cache |
| 83 | 83 | */ |
| 84 | - public static function setCache (Cache $cache) { |
|
| 84 | + public static function setCache(Cache $cache) { |
|
| 85 | 85 | static::$cache = $cache; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @param Api $default |
| 90 | 90 | */ |
| 91 | - public static function setDefault (Api $default) { |
|
| 91 | + public static function setDefault(Api $default) { |
|
| 92 | 92 | self::$default = $default; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * @param LoggerInterface $logger |
| 97 | 97 | */ |
| 98 | - public static function setLogger (LoggerInterface $logger) { |
|
| 98 | + public static function setLogger(LoggerInterface $logger) { |
|
| 99 | 99 | static::$logger = $logger; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param string $token |
| 104 | 104 | */ |
| 105 | - public function __construct (string $token) { |
|
| 105 | + public function __construct(string $token) { |
|
| 106 | 106 | $this->token = $token; |
| 107 | 107 | if (!static::$default) { |
| 108 | 108 | static::$default = $this; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return null|array |
| 119 | 119 | * @internal |
| 120 | 120 | */ |
| 121 | - protected function _exec (string $method, string $path, array $opts = []) { |
|
| 121 | + protected function _exec(string $method, string $path, array $opts = []) { |
|
| 122 | 122 | static::getLogger()->log($method, $path, $opts); |
| 123 | 123 | /** @var resource $ch */ |
| 124 | 124 | $ch = curl_init(); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @return string |
| 168 | 168 | * @internal |
| 169 | 169 | */ |
| 170 | - protected function _getPath (string $path, array $query): string { |
|
| 170 | + protected function _getPath(string $path, array $query): string { |
|
| 171 | 171 | return $query ? $path . '?' . http_build_query($query) : $path; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * @return null|array |
| 177 | 177 | * @internal |
| 178 | 178 | */ |
| 179 | - protected function _jsonDecode (string $json) { |
|
| 180 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 179 | + protected function _jsonDecode(string $json) { |
|
| 180 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | * @return string |
| 186 | 186 | * @internal |
| 187 | 187 | */ |
| 188 | - protected function _jsonEncode (array $data): string { |
|
| 189 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 188 | + protected function _jsonEncode(array $data): string { |
|
| 189 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param string $path |
| 196 | 196 | */ |
| 197 | - public function delete (string $path): void { |
|
| 197 | + public function delete(string $path): void { |
|
| 198 | 198 | $this->_exec('DELETE', $path); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param array $data |
| 209 | 209 | * @return mixed|Data|AbstractEntity |
| 210 | 210 | */ |
| 211 | - public function factory (string $class, $caller, array $data = []) { |
|
| 211 | + public function factory(string $class, $caller, array $data = []) { |
|
| 212 | 212 | return new $class($caller, $data); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param array $options |
| 221 | 221 | * @return null|array |
| 222 | 222 | */ |
| 223 | - public function get (string $path, array $query = [], array $options = []) { |
|
| 223 | + public function get(string $path, array $query = [], array $options = []) { |
|
| 224 | 224 | foreach ($options as $name => $value) { |
| 225 | 225 | $query["opt_{$name}"] = $value; |
| 226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param string $gid |
| 235 | 235 | * @return null|Attachment |
| 236 | 236 | */ |
| 237 | - public function getAttachment (string $gid) { |
|
| 237 | + public function getAttachment(string $gid) { |
|
| 238 | 238 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $gid |
| 245 | 245 | * @return null|CustomField |
| 246 | 246 | */ |
| 247 | - public function getCustomField (string $gid) { |
|
| 247 | + public function getCustomField(string $gid) { |
|
| 248 | 248 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return Workspace |
| 256 | 256 | */ |
| 257 | - public function getDefaultWorkspace () { |
|
| 257 | + public function getDefaultWorkspace() { |
|
| 258 | 258 | return $this->getMe()->getDefaultWorkspace(); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return User |
| 265 | 265 | */ |
| 266 | - public function getMe () { |
|
| 266 | + public function getMe() { |
|
| 267 | 267 | return $this->getUser('me'); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $gid |
| 274 | 274 | * @return null|Portfolio |
| 275 | 275 | */ |
| 276 | - public function getPortfolio (string $gid) { |
|
| 276 | + public function getPortfolio(string $gid) { |
|
| 277 | 277 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @param string $gid |
| 284 | 284 | * @return null|Project |
| 285 | 285 | */ |
| 286 | - public function getProject (string $gid) { |
|
| 286 | + public function getProject(string $gid) { |
|
| 287 | 287 | return $this->load($this, Project::class, "projects/{$gid}"); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param string $gid |
| 294 | 294 | * @return null|Section |
| 295 | 295 | */ |
| 296 | - public function getSection (string $gid) { |
|
| 296 | + public function getSection(string $gid) { |
|
| 297 | 297 | return $this->load($this, Section::class, "sections/{$gid}"); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @param string $gid |
| 304 | 304 | * @return null|Story |
| 305 | 305 | */ |
| 306 | - public function getStory (string $gid) { |
|
| 306 | + public function getStory(string $gid) { |
|
| 307 | 307 | return $this->load($this, Story::class, "stories/{$gid}"); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param string $gid |
| 314 | 314 | * @return null|Tag |
| 315 | 315 | */ |
| 316 | - public function getTag (string $gid) { |
|
| 316 | + public function getTag(string $gid) { |
|
| 317 | 317 | return $this->load($this, Tag::class, "tags/{$gid}"); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @param string $gid |
| 324 | 324 | * @return null|Task |
| 325 | 325 | */ |
| 326 | - public function getTask (string $gid) { |
|
| 326 | + public function getTask(string $gid) { |
|
| 327 | 327 | return $this->load($this, Task::class, "tasks/{$gid}"); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @param string $gid |
| 334 | 334 | * @return null|TaskList |
| 335 | 335 | */ |
| 336 | - public function getTaskList (string $gid) { |
|
| 336 | + public function getTaskList(string $gid) { |
|
| 337 | 337 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param string $gid |
| 344 | 344 | * @return null|Team |
| 345 | 345 | */ |
| 346 | - public function getTeam (string $gid) { |
|
| 346 | + public function getTeam(string $gid) { |
|
| 347 | 347 | return $this->load($this, Team::class, "teams/{$gid}"); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @param string $gid |
| 354 | 354 | * @return null|User |
| 355 | 355 | */ |
| 356 | - public function getUser (string $gid) { |
|
| 356 | + public function getUser(string $gid) { |
|
| 357 | 357 | return $this->load($this, User::class, "users/{$gid}"); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @param string $gid |
| 362 | 362 | * @return ProjectWebhook|TaskWebhook |
| 363 | 363 | */ |
| 364 | - public function getWebhook (string $gid) { |
|
| 364 | + public function getWebhook(string $gid) { |
|
| 365 | 365 | return $this->getCache()->get($gid, $this, function() use ($gid) { |
| 366 | 366 | static $classes = [ |
| 367 | 367 | Project::TYPE => ProjectWebhook::class, |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * @param array $data |
| 383 | 383 | * @return Event |
| 384 | 384 | */ |
| 385 | - public function getWebhookEvent (array $data) { |
|
| 385 | + public function getWebhookEvent(array $data) { |
|
| 386 | 386 | return $this->factory(Event::class, $this, $data); |
| 387 | 387 | } |
| 388 | 388 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @param string $gid |
| 393 | 393 | * @return null|Workspace |
| 394 | 394 | */ |
| 395 | - public function getWorkspace (string $gid) { |
|
| 395 | + public function getWorkspace(string $gid) { |
|
| 396 | 396 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @param string $name |
| 403 | 403 | * @return null|Workspace |
| 404 | 404 | */ |
| 405 | - public function getWorkspaceByName (string $name) { |
|
| 405 | + public function getWorkspaceByName(string $name) { |
|
| 406 | 406 | foreach ($this->getWorkspaces() as $workspace) { |
| 407 | 407 | if ($workspace->getName() === $name) { |
| 408 | 408 | return $workspace; |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | * |
| 417 | 417 | * @return Workspace[] |
| 418 | 418 | */ |
| 419 | - public function getWorkspaces () { |
|
| 419 | + public function getWorkspaces() { |
|
| 420 | 420 | return $this->getMe()->getWorkspaces(); |
| 421 | 421 | } |
| 422 | 422 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * @param array $query |
| 432 | 432 | * @return null|mixed|AbstractEntity |
| 433 | 433 | */ |
| 434 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
| 434 | + public function load($caller, string $class, string $path, array $query = []) { |
|
| 435 | 435 | $key = $this->_getPath($path, $query); |
| 436 | 436 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 437 | 437 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param int $pages |
| 450 | 450 | * @return array|AbstractEntity[] |
| 451 | 451 | */ |
| 452 | - public function loadAll ($caller, string $class, string $path, array $query = [], int $pages = 0) { |
|
| 452 | + public function loadAll($caller, string $class, string $path, array $query = [], int $pages = 0) { |
|
| 453 | 453 | return iterator_to_array($this->loadEach(...func_get_args())); |
| 454 | 454 | } |
| 455 | 455 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * @param int $pages If positive, stops after this many pages have been fetched. |
| 466 | 466 | * @return Generator|AbstractEntity[] |
| 467 | 467 | */ |
| 468 | - public function loadEach ($caller, string $class, string $path, array $query = [], int $pages = 0) { |
|
| 468 | + public function loadEach($caller, string $class, string $path, array $query = [], int $pages = 0) { |
|
| 469 | 469 | $query['opt_expand'] = 'this'; |
| 470 | 470 | $query += ['limit' => 100]; |
| 471 | 471 | $path = $this->_getPath($path, $query); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | * @param array $options |
| 490 | 490 | * @return null|array |
| 491 | 491 | */ |
| 492 | - public function post (string $path, array $data = [], array $options = []) { |
|
| 492 | + public function post(string $path, array $data = [], array $options = []) { |
|
| 493 | 493 | $response = $this->_exec('POST', $path, [ |
| 494 | 494 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 495 | 495 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * @param array $options |
| 506 | 506 | * @return null|array |
| 507 | 507 | */ |
| 508 | - public function put (string $path, array $data = [], array $options = []) { |
|
| 508 | + public function put(string $path, array $data = [], array $options = []) { |
|
| 509 | 509 | $response = $this->_exec('PUT', $path, [ |
| 510 | 510 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 511 | 511 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param null|string $token |
| 525 | 525 | * @return Event[] |
| 526 | 526 | */ |
| 527 | - public function sync ($entity, ?string &$token) { |
|
| 527 | + public function sync($entity, ?string &$token) { |
|
| 528 | 528 | try { |
| 529 | 529 | $response = $this->_exec('GET', $this->_getPath('events', [ |
| 530 | 530 | 'resource' => $entity->getGid(), |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | * @param string $file |
| 555 | 555 | * @return null|array |
| 556 | 556 | */ |
| 557 | - public function upload (string $path, string $file) { |
|
| 557 | + public function upload(string $path, string $file) { |
|
| 558 | 558 | $response = $this->_exec('POST', $path, [ |
| 559 | 559 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 560 | 560 | ]); |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | 'project' => Project::class |
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | - final public function __toString (): string { |
|
| 33 | + final public function __toString(): string { |
|
| 34 | 34 | return "sections/{$this->getGid()}"; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - final protected function _getDir (): string { |
|
| 37 | + final protected function _getDir(): string { |
|
| 38 | 38 | return "{$this->getProject()}/sections"; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param array $filter |
| 43 | 43 | * @return Traversable|Task[] |
| 44 | 44 | */ |
| 45 | - public function getIterator (array $filter = []) { |
|
| 45 | + public function getIterator(array $filter = []) { |
|
| 46 | 46 | $filter['section'] = $this->getGid(); |
| 47 | 47 | return $this->api->loadEach($this, Task::class, 'tasks', $filter); |
| 48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param array $filter |
| 52 | 52 | * @return Task[] |
| 53 | 53 | */ |
| 54 | - public function getTasks (array $filter = []) { |
|
| 54 | + public function getTasks(array $filter = []) { |
|
| 55 | 55 | return iterator_to_array($this->getIterator($filter)); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @depends after-create |
| 62 | 62 | * @return Task |
| 63 | 63 | */ |
| 64 | - public function newTask () { |
|
| 64 | + public function newTask() { |
|
| 65 | 65 | /** @var Task $task */ |
| 66 | 66 | $task = $this->_factory(Task::class); |
| 67 | 67 | return $task->addToProject($this->getProject(), $this); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | 'organization' => Workspace::class |
| 25 | 25 | ]; |
| 26 | 26 | |
| 27 | - final public function __toString (): string { |
|
| 27 | + final public function __toString(): string { |
|
| 28 | 28 | return "teams/{$this->getGid()}"; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param User $user |
| 33 | 33 | * @return $this |
| 34 | 34 | */ |
| 35 | - public function addUser (User $user) { |
|
| 35 | + public function addUser(User $user) { |
|
| 36 | 36 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
| 37 | 37 | return $this; |
| 38 | 38 | } |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | * @param array $filter |
| 46 | 46 | * @return Project[] |
| 47 | 47 | */ |
| 48 | - public function getProjects (array $filter = Project::FILTER_ACTIVE) { |
|
| 48 | + public function getProjects(array $filter = Project::FILTER_ACTIVE) { |
|
| 49 | 49 | return $this->api->loadAll($this, Project::class, "{$this}/projects", $filter); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function getUrl (): string { |
|
| 52 | + public function getUrl(): string { |
|
| 53 | 53 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return User[] |
| 62 | 62 | */ |
| 63 | - public function getUsers () { |
|
| 63 | + public function getUsers() { |
|
| 64 | 64 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param User $user |
| 69 | 69 | * @return $this |
| 70 | 70 | */ |
| 71 | - public function removeUser (User $user) { |
|
| 71 | + public function removeUser(User $user) { |
|
| 72 | 72 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
| 73 | 73 | return $this; |
| 74 | 74 | } |