@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @param PSR16 $psr |
35 | 35 | */ |
36 | - public function __construct (PSR16 $psr) { |
|
36 | + public function __construct(PSR16 $psr) { |
|
37 | 37 | $this->psr = $psr; |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param AbstractEntity $entity |
42 | 42 | * @throws CacheException |
43 | 43 | */ |
44 | - protected function _add (AbstractEntity $entity): void { |
|
44 | + protected function _add(AbstractEntity $entity): void { |
|
45 | 45 | assert($entity->hasGid()); |
46 | 46 | $this->psr->set("asana/{$entity->getGid()}", $entity, $this->_getTtl($entity)); |
47 | 47 | parent::_add($entity); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string[] $keys |
53 | 53 | * @throws CacheException |
54 | 54 | */ |
55 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
55 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
56 | 56 | assert($entity->hasGid()); |
57 | 57 | $gid = $entity->getGid(); |
58 | 58 | $ttl = $this->_getTtl($entity); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return null|AbstractEntity |
71 | 71 | * @throws CacheException |
72 | 72 | */ |
73 | - protected function _get (string $key, $caller) { |
|
73 | + protected function _get(string $key, $caller) { |
|
74 | 74 | if (!$entity = parent::_get($key, $caller) and $entity = $this->psr->get("asana/{$key}")) { |
75 | 75 | if (is_string($entity)) { // gid ref |
76 | 76 | if (!$entity = $this->_get($entity, $caller)) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param AbstractEntity $entity |
91 | 91 | * @return int |
92 | 92 | */ |
93 | - protected function _getTtl (AbstractEntity $entity): int { |
|
93 | + protected function _getTtl(AbstractEntity $entity): int { |
|
94 | 94 | if ($entity instanceof ImmutableInterface) { |
95 | 95 | return strtotime('tomorrow') - time(); |
96 | 96 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * @return bool |
103 | 103 | * @throws CacheException |
104 | 104 | */ |
105 | - protected function _has (string $key): bool { |
|
105 | + protected function _has(string $key): bool { |
|
106 | 106 | return parent::_has($key) or $this->psr->has("asana/{$key}"); |
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return int |
111 | 111 | */ |
112 | - final public function getTtl (): int { |
|
112 | + final public function getTtl(): int { |
|
113 | 113 | return $this->ttl; |
114 | 114 | } |
115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string[] $keys |
118 | 118 | * @throws CacheException |
119 | 119 | */ |
120 | - public function remove (array $keys): void { |
|
120 | + public function remove(array $keys): void { |
|
121 | 121 | parent::remove($keys); |
122 | 122 | foreach ($keys as $key) { |
123 | 123 | $this->psr->delete("asana/{$key}"); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param int $ttl |
129 | 129 | * @return $this |
130 | 130 | */ |
131 | - final public function setTtl (int $ttl) { |
|
131 | + final public function setTtl(int $ttl) { |
|
132 | 132 | $this->ttl = $ttl; |
133 | 133 | return $this; |
134 | 134 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param CustomField $field |
43 | 43 | * @param array $data |
44 | 44 | */ |
45 | - public function __construct (CustomField $field, array $data = []) { |
|
45 | + public function __construct(CustomField $field, array $data = []) { |
|
46 | 46 | $this->parent = $field; |
47 | 47 | parent::__construct($field, $data); |
48 | 48 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @return $this |
52 | 52 | */ |
53 | - public function create () { |
|
53 | + public function create() { |
|
54 | 54 | $this->_create(); |
55 | 55 | $this->parent->_reload('enum_options'); // safe. the options are pooled. |
56 | 56 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @return CustomField |
61 | 61 | */ |
62 | - public function getCustomField () { |
|
62 | + public function getCustomField() { |
|
63 | 63 | return $this->parent; |
64 | 64 | } |
65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param EnumOption $option |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - public function moveAbove (EnumOption $option) { |
|
74 | + public function moveAbove(EnumOption $option) { |
|
75 | 75 | $this->api->post("{$this->parent}/enum_options/insert", [ |
76 | 76 | 'before_enum_option' => $option->getGid(), |
77 | 77 | 'enum_option' => $this->getGid() |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param EnumOption $option |
89 | 89 | * @return $this |
90 | 90 | */ |
91 | - public function moveBelow (EnumOption $option) { |
|
91 | + public function moveBelow(EnumOption $option) { |
|
92 | 92 | $this->api->post("{$this->parent}/enum_options//insert", [ |
93 | 93 | 'after_enum_option' => $option->getGid(), |
94 | 94 | 'enum_option' => $this->getGid() |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return $this |
104 | 104 | */ |
105 | - public function moveFirst () { |
|
105 | + public function moveFirst() { |
|
106 | 106 | $first = $this->parent->getEnumOptions()[0]; |
107 | 107 | if ($first !== $this) { |
108 | 108 | $this->moveAbove($first); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return $this |
117 | 117 | */ |
118 | - public function moveLast () { |
|
118 | + public function moveLast() { |
|
119 | 119 | $options = $this->parent->getEnumOptions(); |
120 | 120 | $last = $options[count($options) - 1]; |
121 | 121 | if ($last !== $this) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param Workspace $organization |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - public function create (Workspace $organization) { |
|
39 | + public function create(Workspace $organization) { |
|
40 | 40 | $this->_set('organization', $organization); |
41 | 41 | return $this->_create(); |
42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return bool |
48 | 48 | */ |
49 | - final public function isActive (): bool { |
|
49 | + final public function isActive(): bool { |
|
50 | 50 | return $this->getState() === self::STATE_ACTIVE; |
51 | 51 | } |
52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool |
57 | 57 | */ |
58 | - final public function isDone (): bool { |
|
58 | + final public function isDone(): bool { |
|
59 | 59 | return $this->isSuccessful() or $this->isFailed(); |
60 | 60 | } |
61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - final public function isFailed (): bool { |
|
67 | + final public function isFailed(): bool { |
|
68 | 68 | return $this->getState() === self::STATE_FAIL; |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool |
75 | 75 | */ |
76 | - final public function isQueued (): bool { |
|
76 | + final public function isQueued(): bool { |
|
77 | 77 | return $this->getState() === self::STATE_QUEUED; |
78 | 78 | } |
79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - final public function isSuccessful (): bool { |
|
85 | + final public function isSuccessful(): bool { |
|
86 | 86 | return $this->getState() === self::STATE_SUCCESS; |
87 | 87 | } |
88 | 88 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param callable $spinner `fn( OrganizationExport $this ): void` |
95 | 95 | * @return $this |
96 | 96 | */ |
97 | - public function wait (callable $spinner = null) { |
|
97 | + public function wait(callable $spinner = null) { |
|
98 | 98 | while (!$this->isDone()) { |
99 | 99 | if ($spinner) { |
100 | 100 | call_user_func($spinner, $this); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'enum_options' => [EnumOption::class], |
64 | 64 | ]; |
65 | 65 | |
66 | - protected function _setData (array $data): void { |
|
66 | + protected function _setData(array $data): void { |
|
67 | 67 | // strip down, removing task values if present |
68 | 68 | $data = array_intersect_key($data, array_flip([ |
69 | 69 | 'gid', |
@@ -83,63 +83,63 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | - final public function hasNotificationsEnabled (): bool { |
|
86 | + final public function hasNotificationsEnabled(): bool { |
|
87 | 87 | return $this->_is('has_notifications_enabled'); |
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @return bool |
92 | 92 | */ |
93 | - final public function isCurrency (): bool { |
|
93 | + final public function isCurrency(): bool { |
|
94 | 94 | return $this->getFormat() === self::FORMAT_CURRENCY; |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - final public function isEnum (): bool { |
|
100 | + final public function isEnum(): bool { |
|
101 | 101 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return bool |
106 | 106 | */ |
107 | - final public function isGlobalToWorkspace (): bool { |
|
107 | + final public function isGlobalToWorkspace(): bool { |
|
108 | 108 | return $this->_is('is_global_to_workspace'); |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @return bool |
113 | 113 | */ |
114 | - final public function isIdentifier (): bool { |
|
114 | + final public function isIdentifier(): bool { |
|
115 | 115 | return $this->getFormat() === self::FORMAT_IDENTIFIER; |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | 119 | * @return bool |
120 | 120 | */ |
121 | - final public function isNumber (): bool { |
|
121 | + final public function isNumber(): bool { |
|
122 | 122 | return $this->getResourceSubtype() === self::TYPE_NUMBER; |
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @return bool |
127 | 127 | */ |
128 | - final public function isPercentage (): bool { |
|
128 | + final public function isPercentage(): bool { |
|
129 | 129 | return $this->getFormat() === self::FORMAT_PERCENTAGE; |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @return bool |
134 | 134 | */ |
135 | - final public function isText (): bool { |
|
135 | + final public function isText(): bool { |
|
136 | 136 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * @return EnumOption |
141 | 141 | */ |
142 | - public function newEnumOption () { |
|
142 | + public function newEnumOption() { |
|
143 | 143 | return $this->api->factory($this, EnumOption::class); |
144 | 144 | } |
145 | 145 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param bool $global |
148 | 148 | * @return $this |
149 | 149 | */ |
150 | - final public function setGlobalToWorkspace (bool $global) { |
|
150 | + final public function setGlobalToWorkspace(bool $global) { |
|
151 | 151 | return $this->_set('is_global_to_workspace', $global); |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param bool $enabled |
156 | 156 | * @return $this |
157 | 157 | */ |
158 | - final public function setNotificationsEnabled (bool $enabled) { |
|
158 | + final public function setNotificationsEnabled(bool $enabled) { |
|
159 | 159 | return $this->_set('has_notifications_enabled', $enabled); |
160 | 160 | } |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param callable $cmp `fn( EnumOption $a, EnumOption $b ): int` |
164 | 164 | * @return $this |
165 | 165 | */ |
166 | - public function sortEnumOptions (callable $cmp) { |
|
166 | + public function sortEnumOptions(callable $cmp) { |
|
167 | 167 | if ($options = $this->getEnumOptions()) { |
168 | 168 | $prev = $options[0]; // first option on remote |
169 | 169 | usort($options, $cmp); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param Workspace $workspace |
38 | 38 | * @return $this |
39 | 39 | */ |
40 | - public function addToWorkspace (Workspace $workspace) { |
|
40 | + public function addToWorkspace(Workspace $workspace) { |
|
41 | 41 | return $this->_addWithPost("{$workspace}/addUser", [ |
42 | 42 | 'user' => $this->getGid() |
43 | 43 | ], 'workspaces', [$workspace]); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return Workspace |
50 | 50 | */ |
51 | - public function getDefaultWorkspace () { |
|
51 | + public function getDefaultWorkspace() { |
|
52 | 52 | return $this->getWorkspaces()[0]; |
53 | 53 | } |
54 | 54 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param null|Workspace $workspace Falls back to the default workspace. |
57 | 57 | * @return Portfolio[] |
58 | 58 | */ |
59 | - public function getFavoritePortfolios (Workspace $workspace = null) { |
|
59 | + public function getFavoritePortfolios(Workspace $workspace = null) { |
|
60 | 60 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
61 | 61 | } |
62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param null|Workspace $workspace Falls back to the default workspace. |
65 | 65 | * @return Project[] |
66 | 66 | */ |
67 | - public function getFavoriteProjects (Workspace $workspace = null) { |
|
67 | + public function getFavoriteProjects(Workspace $workspace = null) { |
|
68 | 68 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param null|Workspace $workspace Falls back to the default workspace. |
73 | 73 | * @return Tag[] |
74 | 74 | */ |
75 | - public function getFavoriteTags (Workspace $workspace = null) { |
|
75 | + public function getFavoriteTags(Workspace $workspace = null) { |
|
76 | 76 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
77 | 77 | } |
78 | 78 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param null|Workspace $workspace Falls back to the default workspace. |
81 | 81 | * @return Team[] |
82 | 82 | */ |
83 | - public function getFavoriteTeams (Workspace $workspace = null) { |
|
83 | + public function getFavoriteTeams(Workspace $workspace = null) { |
|
84 | 84 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
85 | 85 | } |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param null|Workspace $workspace Falls back to the default workspace. |
89 | 89 | * @return User[] |
90 | 90 | */ |
91 | - public function getFavoriteUsers (Workspace $workspace = null) { |
|
91 | + public function getFavoriteUsers(Workspace $workspace = null) { |
|
92 | 92 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
93 | 93 | } |
94 | 94 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param null|Workspace $workspace Falls back to the default workspace. |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) { |
|
101 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) { |
|
102 | 102 | return $this->api->loadAll($this, $class, "{$this}/favorites", [ |
103 | 103 | 'resource_type' => $resourceType, |
104 | 104 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid() |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return string[] |
110 | 110 | */ |
111 | - public function getPoolKeys () { |
|
111 | + public function getPoolKeys() { |
|
112 | 112 | $keys = parent::getPoolKeys(); |
113 | 113 | |
114 | 114 | // include email as a key if it's loaded |
@@ -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->api->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->api->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 = Task::GET_INCOMPLETE) { |
|
149 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
150 | 150 | $filter['assignee'] = $this->getGid(); |
151 | 151 | $filter += ['workspace' => $this->api->getDefaultWorkspace()->getGid()]; |
152 | 152 | return $this->api->loadAll($this, Task::class, 'tasks', $filter); |
@@ -160,7 +160,7 @@ 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 | ]); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | /** |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - final public function getUrl (): string { |
|
172 | + final public function getUrl(): string { |
|
173 | 173 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
174 | 174 | } |
175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param Workspace $workspace |
178 | 178 | * @return $this |
179 | 179 | */ |
180 | - public function removeFromWorkspace (Workspace $workspace) { |
|
180 | + public function removeFromWorkspace(Workspace $workspace) { |
|
181 | 181 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
182 | 182 | 'user' => $this->getGid() |
183 | 183 | ], 'workspaces', [$workspace]); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $token |
43 | 43 | * @param null|Pool $pool |
44 | 44 | */ |
45 | - public function __construct (string $token, Pool $pool = null) { |
|
45 | + public function __construct(string $token, Pool $pool = null) { |
|
46 | 46 | $this->token = $token; |
47 | 47 | $this->pool = $pool ?? new Pool(); |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param array $curlOpts |
56 | 56 | * @return null|array |
57 | 57 | */ |
58 | - public function call (string $method, string $path, array $curlOpts = []) { |
|
58 | + public function call(string $method, string $path, array $curlOpts = []) { |
|
59 | 59 | $this->getLog()->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
60 | 60 | $ch = curl_init(); |
61 | 61 | curl_setopt_array($ch, [ |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | throw new AsanaError(curl_errno($ch), curl_error($ch), $info); |
79 | 79 | case 200: |
80 | 80 | case 201: |
81 | - return json_decode($res[1], true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
81 | + return json_decode($res[1], true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
82 | 82 | case 404: |
83 | 83 | return null; |
84 | 84 | case 429: |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param string $path |
100 | 100 | */ |
101 | - public function delete (string $path): void { |
|
101 | + public function delete(string $path): void { |
|
102 | 102 | $this->call('DELETE', $path); |
103 | 103 | } |
104 | 104 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param array $data |
113 | 113 | * @return mixed|Data|AbstractEntity |
114 | 114 | */ |
115 | - public function factory ($caller, string $class, array $data = []) { |
|
115 | + public function factory($caller, string $class, array $data = []) { |
|
116 | 116 | return new $class($caller, $data); |
117 | 117 | } |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param array $query |
124 | 124 | * @return null|array |
125 | 125 | */ |
126 | - public function get (string $path, array $query = []) { |
|
126 | + public function get(string $path, array $query = []) { |
|
127 | 127 | return $this->call('GET', $path . '?' . http_build_query($query))['data'] ?? null; |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param string $gid |
134 | 134 | * @return null|Attachment |
135 | 135 | */ |
136 | - public function getAttachment (string $gid) { |
|
136 | + public function getAttachment(string $gid) { |
|
137 | 137 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $gid |
144 | 144 | * @return null|CustomField |
145 | 145 | */ |
146 | - public function getCustomField (string $gid) { |
|
146 | + public function getCustomField(string $gid) { |
|
147 | 147 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
148 | 148 | } |
149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return Workspace |
156 | 156 | */ |
157 | - public function getDefaultWorkspace () { |
|
157 | + public function getDefaultWorkspace() { |
|
158 | 158 | return $this->getMe()->getDefaultWorkspace(); |
159 | 159 | } |
160 | 160 | |
@@ -162,21 +162,21 @@ discard block |
||
162 | 162 | * @param string $gid |
163 | 163 | * @return null|Job |
164 | 164 | */ |
165 | - public function getJob (string $gid) { |
|
165 | + public function getJob(string $gid) { |
|
166 | 166 | return $this->load($this, Job::class, "jobs/{$gid}"); |
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @return LoggerInterface |
171 | 171 | */ |
172 | - public function getLog () { |
|
172 | + public function getLog() { |
|
173 | 173 | return $this->log ?? $this->log = new NullLogger(); |
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | 177 | * @return User |
178 | 178 | */ |
179 | - public function getMe () { |
|
179 | + public function getMe() { |
|
180 | 180 | return $this->getUser('me'); |
181 | 181 | } |
182 | 182 | |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | * @param string $gid |
185 | 185 | * @return null|OrganizationExport |
186 | 186 | */ |
187 | - public function getOrganizationExport (string $gid) { |
|
187 | + public function getOrganizationExport(string $gid) { |
|
188 | 188 | return $this->load($this, OrganizationExport::class, "organization_exports/{$gid}"); |
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @return Pool |
193 | 193 | */ |
194 | - public function getPool () { |
|
194 | + public function getPool() { |
|
195 | 195 | return $this->pool; |
196 | 196 | } |
197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param string $gid |
202 | 202 | * @return null|Portfolio |
203 | 203 | */ |
204 | - public function getPortfolio (string $gid) { |
|
204 | + public function getPortfolio(string $gid) { |
|
205 | 205 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
206 | 206 | } |
207 | 207 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param string $gid |
212 | 212 | * @return null|Project |
213 | 213 | */ |
214 | - public function getProject (string $gid) { |
|
214 | + public function getProject(string $gid) { |
|
215 | 215 | return $this->load($this, Project::class, "projects/{$gid}"); |
216 | 216 | } |
217 | 217 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param string $gid |
220 | 220 | * @return null|ProjectWebhook |
221 | 221 | */ |
222 | - public function getProjectWebhook (string $gid) { |
|
222 | + public function getProjectWebhook(string $gid) { |
|
223 | 223 | return $this->load($this, ProjectWebhook::class, "webhooks/{$gid}"); |
224 | 224 | } |
225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param string $gid |
230 | 230 | * @return null|Section |
231 | 231 | */ |
232 | - public function getSection (string $gid) { |
|
232 | + public function getSection(string $gid) { |
|
233 | 233 | return $this->load($this, Section::class, "sections/{$gid}"); |
234 | 234 | } |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param string $gid |
240 | 240 | * @return null|Story |
241 | 241 | */ |
242 | - public function getStory (string $gid) { |
|
242 | + public function getStory(string $gid) { |
|
243 | 243 | return $this->load($this, Story::class, "stories/{$gid}"); |
244 | 244 | } |
245 | 245 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string $gid |
250 | 250 | * @return null|Tag |
251 | 251 | */ |
252 | - public function getTag (string $gid) { |
|
252 | + public function getTag(string $gid) { |
|
253 | 253 | return $this->load($this, Tag::class, "tags/{$gid}"); |
254 | 254 | } |
255 | 255 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string $gid |
260 | 260 | * @return null|Task |
261 | 261 | */ |
262 | - public function getTask (string $gid) { |
|
262 | + public function getTask(string $gid) { |
|
263 | 263 | return $this->load($this, Task::class, "tasks/{$gid}"); |
264 | 264 | } |
265 | 265 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param string $gid |
270 | 270 | * @return null|TaskList |
271 | 271 | */ |
272 | - public function getTaskList (string $gid) { |
|
272 | + public function getTaskList(string $gid) { |
|
273 | 273 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
274 | 274 | } |
275 | 275 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param string $gid |
278 | 278 | * @return null|TaskWebhook |
279 | 279 | */ |
280 | - public function getTaskWebhook (string $gid) { |
|
280 | + public function getTaskWebhook(string $gid) { |
|
281 | 281 | return $this->load($this, TaskWebhook::class, "webhooks/{$gid}"); |
282 | 282 | } |
283 | 283 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param string $gid |
288 | 288 | * @return null|Team |
289 | 289 | */ |
290 | - public function getTeam (string $gid) { |
|
290 | + public function getTeam(string $gid) { |
|
291 | 291 | return $this->load($this, Team::class, "teams/{$gid}"); |
292 | 292 | } |
293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param string $gid |
298 | 298 | * @return null|User |
299 | 299 | */ |
300 | - public function getUser (string $gid) { |
|
300 | + public function getUser(string $gid) { |
|
301 | 301 | return $this->load($this, User::class, "users/{$gid}"); |
302 | 302 | } |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param array $data |
310 | 310 | * @return Event |
311 | 311 | */ |
312 | - public function getWebhookEvent (array $data) { |
|
312 | + public function getWebhookEvent(array $data) { |
|
313 | 313 | return $this->factory($this, Event::class, $data); |
314 | 314 | } |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param string $gid |
320 | 320 | * @return null|Workspace |
321 | 321 | */ |
322 | - public function getWorkspace (string $gid) { |
|
322 | + public function getWorkspace(string $gid) { |
|
323 | 323 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
324 | 324 | } |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $query |
333 | 333 | * @return null|mixed|AbstractEntity |
334 | 334 | */ |
335 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
335 | + public function load($caller, string $class, string $path, array $query = []) { |
|
336 | 336 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
337 | 337 | $query['opt_expand'] = 'this'; |
338 | 338 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param array $query |
353 | 353 | * @return array|AbstractEntity[] |
354 | 354 | */ |
355 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
355 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
356 | 356 | return iterator_to_array($this->loadEach(...func_get_args())); |
357 | 357 | } |
358 | 358 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param array $query `limit` can exceed `100` here. |
368 | 368 | * @return Generator|AbstractEntity[] |
369 | 369 | */ |
370 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
370 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
371 | 371 | $query['opt_expand'] = 'this'; |
372 | 372 | $remain = $query['limit'] ?? PHP_INT_MAX; |
373 | 373 | do { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | * @param array $options |
392 | 392 | * @return null|array |
393 | 393 | */ |
394 | - public function post (string $path, array $data = [], array $options = []) { |
|
394 | + public function post(string $path, array $data = [], array $options = []) { |
|
395 | 395 | return $this->call('POST', $path, [ |
396 | 396 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
397 | 397 | CURLOPT_POSTFIELDS => json_encode([ |
398 | 398 | 'options' => $options, |
399 | 399 | 'data' => $data |
400 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
400 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
401 | 401 | ])['data'] ?? null; |
402 | 402 | } |
403 | 403 | |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | * @param array $options |
410 | 410 | * @return null|array |
411 | 411 | */ |
412 | - public function put (string $path, array $data = [], array $options = []) { |
|
412 | + public function put(string $path, array $data = [], array $options = []) { |
|
413 | 413 | return $this->call('PUT', $path, [ |
414 | 414 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
415 | 415 | CURLOPT_POSTFIELDS => json_encode([ |
416 | 416 | 'options' => $options, |
417 | 417 | 'data' => $data |
418 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
418 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
419 | 419 | ])['data'] ?? null; |
420 | 420 | } |
421 | 421 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param LoggerInterface $log |
424 | 424 | * @return $this |
425 | 425 | */ |
426 | - final public function setLog (LoggerInterface $log) { |
|
426 | + final public function setLog(LoggerInterface $log) { |
|
427 | 427 | $this->log = $log; |
428 | 428 | return $this; |
429 | 429 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function create () { |
|
26 | + public function create() { |
|
27 | 27 | assert(!$this->hasGid()); |
28 | 28 | $path = static::DIR; |
29 | 29 | if (isset($this->parent)) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param User $user |
67 | 67 | * @return $this |
68 | 68 | */ |
69 | - public function addMember (User $user) { |
|
69 | + public function addMember(User $user) { |
|
70 | 70 | return $this->addMembers([$user]); |
71 | 71 | } |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param User[] $users |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function addMembers (array $users) { |
|
77 | + public function addMembers(array $users) { |
|
78 | 78 | return $this->_addWithPost("{$this}/addMembers", [ |
79 | 79 | 'members' => array_column($users, 'gid') |
80 | 80 | ], 'members', $users); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param Project $project |
85 | 85 | * @return $this |
86 | 86 | */ |
87 | - public function addProject (Project $project) { |
|
87 | + public function addProject(Project $project) { |
|
88 | 88 | $this->api->post("{$this}/addItem", ['item' => $project->getGid()]); |
89 | 89 | return $this; |
90 | 90 | } |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return Traversable|Project[] |
96 | 96 | */ |
97 | - public function getIterator () { |
|
97 | + public function getIterator() { |
|
98 | 98 | return $this->api->loadEach($this, Project::class, "{$this}/items"); |
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @return Project[] |
103 | 103 | */ |
104 | - public function getProjects () { |
|
104 | + public function getProjects() { |
|
105 | 105 | return iterator_to_array($this); |
106 | 106 | } |
107 | 107 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param User $user |
110 | 110 | * @return $this |
111 | 111 | */ |
112 | - public function removeMember (User $user) { |
|
112 | + public function removeMember(User $user) { |
|
113 | 113 | return $this->removeMembers([$user]); |
114 | 114 | } |
115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param User[] $users |
118 | 118 | * @return $this |
119 | 119 | */ |
120 | - public function removeMembers (array $users) { |
|
120 | + public function removeMembers(array $users) { |
|
121 | 121 | return $this->_removeWithPost("{$this}/removeMembers", [ |
122 | 122 | 'members' => array_column($users, 'gid') |
123 | 123 | ], 'members', $users); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param Project $project |
128 | 128 | * @return $this |
129 | 129 | */ |
130 | - public function removeProject (Project $project) { |
|
130 | + public function removeProject(Project $project) { |
|
131 | 131 | $this->api->post("{$this}/removeItem", ['item' => $project->getGid()]); |
132 | 132 | return $this; |
133 | 133 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param callable $filter `fn( Project $project ): bool` |
137 | 137 | * @return Project[] |
138 | 138 | */ |
139 | - public function selectProjects (callable $filter) { |
|
139 | + public function selectProjects(callable $filter) { |
|
140 | 140 | return $this->_select($this, $filter); |
141 | 141 | } |
142 | 142 | } |
143 | 143 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param User $user |
31 | 31 | * @return $this |
32 | 32 | */ |
33 | - public function addUser (User $user) { |
|
33 | + public function addUser(User $user) { |
|
34 | 34 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
35 | 35 | return $this; |
36 | 36 | } |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @param array $filter |
44 | 44 | * @return Project[] |
45 | 45 | */ |
46 | - public function getProjects (array $filter = Project::GET_ACTIVE) { |
|
46 | + public function getProjects(array $filter = Project::GET_ACTIVE) { |
|
47 | 47 | return $this->api->loadAll($this, Project::class, "{$this}/projects", $filter); |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - final public function getUrl (): string { |
|
53 | + final public function getUrl(): string { |
|
54 | 54 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
55 | 55 | } |
56 | 56 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return User[] |
63 | 63 | */ |
64 | - public function getUsers () { |
|
64 | + public function getUsers() { |
|
65 | 65 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return Project |
72 | 72 | */ |
73 | - public function newProject () { |
|
73 | + public function newProject() { |
|
74 | 74 | /** @var Project $project */ |
75 | 75 | $project = $this->api->factory($this, Project::class, [ |
76 | 76 | 'workspace' => $this->getOrganization() |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param User $user |
83 | 83 | * @return $this |
84 | 84 | */ |
85 | - public function removeUser (User $user) { |
|
85 | + public function removeUser(User $user) { |
|
86 | 86 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
87 | 87 | return $this; |
88 | 88 | } |