@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | const TYPE = 'workspace'; |
28 | 28 | |
29 | - final public function __toString (): string { |
|
29 | + final public function __toString(): string { |
|
30 | 30 | return "workspaces/{$this->getGid()}"; |
31 | 31 | } |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return OrganizationExport |
37 | 37 | */ |
38 | - public function export () { |
|
38 | + public function export() { |
|
39 | 39 | assert($this->isOrganization()); |
40 | 40 | /** @var OrganizationExport $export */ |
41 | 41 | $export = $this->factory(OrganizationExport::class); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param int $limit 1-100 |
54 | 54 | * @return array|AbstractEntity[] |
55 | 55 | */ |
56 | - protected function find (string $class, string $resourceType, string $text, int $limit = 20) { |
|
56 | + protected function find(string $class, string $resourceType, string $text, int $limit = 20) { |
|
57 | 57 | return $this->loadAll($class, "{$this}/typeahead", [ |
58 | 58 | 'resource_type' => $resourceType, |
59 | 59 | 'query' => $text, |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param int $limit 1-100 |
69 | 69 | * @return CustomField[] |
70 | 70 | */ |
71 | - public function findCustomFields (string $text, int $limit = 20) { |
|
71 | + public function findCustomFields(string $text, int $limit = 20) { |
|
72 | 72 | return $this->find(CustomField::class, CustomField::TYPE, $text, $limit); |
73 | 73 | } |
74 | 74 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param int $limit 1-100 |
80 | 80 | * @return Portfolio[] |
81 | 81 | */ |
82 | - public function findPortfolios (string $text, int $limit = 20) { |
|
82 | + public function findPortfolios(string $text, int $limit = 20) { |
|
83 | 83 | return $this->find(Portfolio::class, Portfolio::TYPE, $text, $limit); |
84 | 84 | } |
85 | 85 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param int $limit 1-100 |
91 | 91 | * @return Project[] |
92 | 92 | */ |
93 | - public function findProjects (string $text, int $limit = 20) { |
|
93 | + public function findProjects(string $text, int $limit = 20) { |
|
94 | 94 | return $this->find(Project::class, Project::TYPE, $text, $limit); |
95 | 95 | } |
96 | 96 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param int $limit 1-100 |
102 | 102 | * @return Tag[] |
103 | 103 | */ |
104 | - public function findTags (string $text, int $limit = 20) { |
|
104 | + public function findTags(string $text, int $limit = 20) { |
|
105 | 105 | return $this->find(Tag::class, Tag::TYPE, $text, $limit); |
106 | 106 | } |
107 | 107 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param int $limit 1-100 |
113 | 113 | * @return Task[] |
114 | 114 | */ |
115 | - public function findTasks (string $text, int $limit = 20) { |
|
115 | + public function findTasks(string $text, int $limit = 20) { |
|
116 | 116 | return $this->find(Task::class, Task::TYPE, $text, $limit); |
117 | 117 | } |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param int $limit 1-100 |
124 | 124 | * @return User[] |
125 | 125 | */ |
126 | - public function findUsers (string $text, int $limit = 20) { |
|
126 | + public function findUsers(string $text, int $limit = 20) { |
|
127 | 127 | return $this->find(User::class, User::TYPE, $text, $limit); |
128 | 128 | } |
129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param array $filter |
132 | 132 | * @return Project[] |
133 | 133 | */ |
134 | - public function getProjects (array $filter = []) { |
|
134 | + public function getProjects(array $filter = []) { |
|
135 | 135 | $filter['workspace'] = $this->getGid(); |
136 | 136 | return $this->loadAll(Project::class, 'projects', $filter); |
137 | 137 | } |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | /** |
140 | 140 | * @return Tag[] |
141 | 141 | */ |
142 | - public function getTags () { |
|
142 | + public function getTags() { |
|
143 | 143 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @return Team[] |
148 | 148 | */ |
149 | - public function getTeams () { |
|
149 | + public function getTeams() { |
|
150 | 150 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
151 | 151 | } |
152 | 152 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $email |
155 | 155 | * @return null|User |
156 | 156 | */ |
157 | - public function getUserByEmail (string $email) { |
|
157 | + public function getUserByEmail(string $email) { |
|
158 | 158 | return $this->api->getCache()->get($email, $this, function() use ($email) { |
159 | 159 | foreach ($this->getUsers() as $user) { |
160 | 160 | if ($user->getEmail() === $email) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * @return User[] |
170 | 170 | */ |
171 | - public function getUsers () { |
|
171 | + public function getUsers() { |
|
172 | 172 | return $this->loadAll(User::class, "{$this}/users"); |
173 | 173 | } |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return ProjectWebhook[]|TaskWebhook[] |
179 | 179 | */ |
180 | - public function getWebhooks () { |
|
180 | + public function getWebhooks() { |
|
181 | 181 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
182 | 182 | return array_map(function(array $each) { |
183 | 183 | return $this->api->getCache()->get($each['gid'], $this, function() use ($each) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * @return bool |
195 | 195 | */ |
196 | - public function isOrganization (): bool { |
|
196 | + public function isOrganization(): bool { |
|
197 | 197 | return $this->_is('is_organization'); |
198 | 198 | } |
199 | 199 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return CustomField |
204 | 204 | */ |
205 | - public function newCustomField () { |
|
205 | + public function newCustomField() { |
|
206 | 206 | /** @var CustomField $field */ |
207 | 207 | $field = $this->factory(CustomField::class); |
208 | 208 | return $field->setWorkspace($this); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return Portfolio |
215 | 215 | */ |
216 | - public function newPortfolio () { |
|
216 | + public function newPortfolio() { |
|
217 | 217 | /** @var Portfolio $portfolio */ |
218 | 218 | $portfolio = $this->factory(Portfolio::class); |
219 | 219 | return $portfolio->setWorkspace($this); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return Project |
226 | 226 | */ |
227 | - public function newProject () { |
|
227 | + public function newProject() { |
|
228 | 228 | /** @var Project $project */ |
229 | 229 | $project = $this->factory(Project::class); |
230 | 230 | return $project->setWorkspace($this); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return Tag |
237 | 237 | */ |
238 | - public function newTag () { |
|
238 | + public function newTag() { |
|
239 | 239 | /** @var Tag $tag */ |
240 | 240 | $tag = $this->factory(Tag::class); |
241 | 241 | return $tag->setWorkspace($this); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return Task |
248 | 248 | */ |
249 | - public function newTask () { |
|
249 | + public function newTask() { |
|
250 | 250 | /** @var Task $task */ |
251 | 251 | $task = $this->factory(Task::class); |
252 | 252 | return $task->setWorkspace($this); |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | const TYPE_NUMBER = 'number'; |
40 | 40 | const TYPE_TEXT = 'text'; |
41 | 41 | |
42 | - final public function __toString (): string { |
|
42 | + final public function __toString(): string { |
|
43 | 43 | return "custom_fields/{$this->getGid()}"; |
44 | 44 | } |
45 | 45 | |
46 | - final protected function _getDir (): string { |
|
46 | + final protected function _getDir(): string { |
|
47 | 47 | return 'custom_fields'; |
48 | 48 | } |
49 | 49 | |
50 | - protected function _getMap (): array { |
|
50 | + protected function _getMap(): array { |
|
51 | 51 | return [ |
52 | 52 | 'enum_options' => [EnumOption::class], |
53 | 53 | ]; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $name |
58 | 58 | * @return EnumOption |
59 | 59 | */ |
60 | - public function addEnumOption (string $name) { |
|
60 | + public function addEnumOption(string $name) { |
|
61 | 61 | /** @var EnumOption $option */ |
62 | 62 | $option = $this->factory(EnumOption::class); |
63 | 63 | $option->setName($name); |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - public function hasNotificationsEnabled (): bool { |
|
77 | + public function hasNotificationsEnabled(): bool { |
|
78 | 78 | return $this->_is('has_notifications_enabled'); |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | - public function isEnum (): bool { |
|
84 | + public function isEnum(): bool { |
|
85 | 85 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public function isGlobalToWorkspace (): bool { |
|
91 | + public function isGlobalToWorkspace(): bool { |
|
92 | 92 | return $this->_is('is_global_to_workspace'); |
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @return bool |
97 | 97 | */ |
98 | - final public function isText (): bool { |
|
98 | + final public function isText(): bool { |
|
99 | 99 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
100 | 100 | } |
101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param bool $flag |
104 | 104 | * @return $this |
105 | 105 | */ |
106 | - public function setGlobalToWorkspace (bool $flag) { |
|
106 | + public function setGlobalToWorkspace(bool $flag) { |
|
107 | 107 | return $this->_set('is_global_to_workspace', $flag); |
108 | 108 | } |
109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param bool $flag |
112 | 112 | * @return $this |
113 | 113 | */ |
114 | - public function setNotificationsEnabled (bool $flag) { |
|
114 | + public function setNotificationsEnabled(bool $flag) { |
|
115 | 115 | return $this->_set('has_notifications_enabled', $flag); |
116 | 116 | } |
117 | 117 |
@@ -15,14 +15,14 @@ |
||
15 | 15 | * |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - abstract protected function _getDir (): string; |
|
18 | + abstract protected function _getDir(): string; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * `POST` |
22 | 22 | * |
23 | 23 | * @return $this |
24 | 24 | */ |
25 | - public function create () { |
|
25 | + public function create() { |
|
26 | 26 | /** @var Api $api */ |
27 | 27 | $api = $this->api; |
28 | 28 | $remote = $api->post($this->_getDir(), $this->getDiff(), ['expand' => 'this']); |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | |
32 | 32 | const TYPE = 'portfolio'; |
33 | 33 | |
34 | - final public function __toString (): string { |
|
34 | + final public function __toString(): string { |
|
35 | 35 | return "portfolios/{$this->getGid()}"; |
36 | 36 | } |
37 | 37 | |
38 | - final protected function _getDir (): string { |
|
38 | + final protected function _getDir(): string { |
|
39 | 39 | return 'portfolios'; |
40 | 40 | } |
41 | 41 | |
42 | - protected function _getMap (): array { |
|
42 | + protected function _getMap(): array { |
|
43 | 43 | return [ |
44 | 44 | 'created_by' => User::class, |
45 | 45 | 'custom_fields' => [CustomField::class], |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Project $item |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function addItem (Project $item) { |
|
57 | + public function addItem(Project $item) { |
|
58 | 58 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
59 | 59 | return $this; |
60 | 60 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param User $user |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function addMember (User $user) { |
|
66 | + public function addMember(User $user) { |
|
67 | 67 | return $this->addMembers([$user]); |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param User[] $users |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - public function addMembers (array $users) { |
|
74 | + public function addMembers(array $users) { |
|
75 | 75 | if ($this->hasGid()) { |
76 | 76 | $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]); |
77 | 77 | $this->_merge('members', $users); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @depends after-create |
87 | 87 | * @return Project[] |
88 | 88 | */ |
89 | - public function getItems () { |
|
89 | + public function getItems() { |
|
90 | 90 | return $this->loadAll(Project::class, "{$this}/items"); |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param Project $item |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function removeItem (Project $item) { |
|
98 | + public function removeItem(Project $item) { |
|
99 | 99 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
100 | 100 | return $this; |
101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param User $user |
105 | 105 | * @return $this |
106 | 106 | */ |
107 | - public function removeMember (User $user) { |
|
107 | + public function removeMember(User $user) { |
|
108 | 108 | return $this->removeMembers([$user]); |
109 | 109 | } |
110 | 110 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param User[] $users |
113 | 113 | * @return $this |
114 | 114 | */ |
115 | - public function removeMembers (array $users) { |
|
115 | + public function removeMembers(array $users) { |
|
116 | 116 | if ($this->hasGid()) { |
117 | 117 | $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]); |
118 | 118 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | const LAYOUT_BOARD = 'board'; |
58 | 58 | const LAYOUT_LIST = 'list'; |
59 | 59 | |
60 | - final public function __toString (): string { |
|
60 | + final public function __toString(): string { |
|
61 | 61 | return "projects/{$this->getGid()}"; |
62 | 62 | } |
63 | 63 | |
64 | - final protected function _getDir (): string { |
|
64 | + final protected function _getDir(): string { |
|
65 | 65 | return 'projects'; |
66 | 66 | } |
67 | 67 | |
68 | - protected function _getMap (): array { |
|
68 | + protected function _getMap(): array { |
|
69 | 69 | return [ |
70 | 70 | 'current_status' => Status::class, |
71 | 71 | 'custom_fields' => [CustomField::class], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param User $user |
83 | 83 | * @return $this |
84 | 84 | */ |
85 | - public function addMember (User $user) { |
|
85 | + public function addMember(User $user) { |
|
86 | 86 | return $this->addMembers([$user]); |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param User[] $users |
92 | 92 | * @return $this |
93 | 93 | */ |
94 | - public function addMembers (array $users) { |
|
94 | + public function addMembers(array $users) { |
|
95 | 95 | $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]); |
96 | 96 | $this->_merge('members', $users); |
97 | 97 | return $this; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $target |
103 | 103 | * @return ProjectWebhook |
104 | 104 | */ |
105 | - public function addWebhook (string $target) { |
|
105 | + public function addWebhook(string $target) { |
|
106 | 106 | /** @var ProjectWebhook $webhook */ |
107 | 107 | $webhook = $this->factory(ProjectWebhook::class); |
108 | 108 | return $webhook->create($this, $target); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param array $schedule |
128 | 128 | * @return Job |
129 | 129 | */ |
130 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
130 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
131 | 131 | $data = ['name' => $name]; |
132 | 132 | if ($team) { |
133 | 133 | $data['team'] = $team->getGid(); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param null|string $token |
150 | 150 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
151 | 151 | */ |
152 | - public function getEvents (&$token) { |
|
152 | + public function getEvents(&$token) { |
|
153 | 153 | return $this->api->sync($this, $token); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @depends after-create |
158 | 158 | * @return Section[] |
159 | 159 | */ |
160 | - public function getSections () { |
|
160 | + public function getSections() { |
|
161 | 161 | return $this->loadAll(Section::class, "{$this}/sections"); |
162 | 162 | } |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @depends after-create |
166 | 166 | * @return Status[] |
167 | 167 | */ |
168 | - public function getStatuses () { |
|
168 | + public function getStatuses() { |
|
169 | 169 | return $this->loadAll(Status::class, "{$this}/project_statuses"); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param array $query |
175 | 175 | * @return Task[] |
176 | 176 | */ |
177 | - public function getTasks (array $query = []) { |
|
177 | + public function getTasks(array $query = []) { |
|
178 | 178 | $query['project'] = $this->getGid(); |
179 | 179 | return $this->loadAll(Task::class, "tasks", $query); |
180 | 180 | } |
@@ -183,25 +183,25 @@ discard block |
||
183 | 183 | * @depends after-create |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - public function getUrl (): string { |
|
186 | + public function getUrl(): string { |
|
187 | 187 | return "https://app.asana.com/0/{$this->getGid()}"; |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @return ProjectWebhook[] |
192 | 192 | */ |
193 | - public function getWebhooks () { |
|
193 | + public function getWebhooks() { |
|
194 | 194 | return $this->loadAll(ProjectWebhook::class, 'webhooks', [ |
195 | 195 | 'workspace' => $this->getWorkspace()->getGid(), |
196 | 196 | 'resource' => $this->getGid() |
197 | 197 | ]); |
198 | 198 | } |
199 | 199 | |
200 | - public function isBoard (): bool { |
|
200 | + public function isBoard(): bool { |
|
201 | 201 | return $this->getLayout() === self::LAYOUT_BOARD; |
202 | 202 | } |
203 | 203 | |
204 | - public function isList (): bool { |
|
204 | + public function isList(): bool { |
|
205 | 205 | return $this->getLayout() === self::LAYOUT_LIST; |
206 | 206 | } |
207 | 207 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @depends after-create |
210 | 210 | * @return Section |
211 | 211 | */ |
212 | - public function newSection () { |
|
212 | + public function newSection() { |
|
213 | 213 | return $this->factory(Section::class, ['projects' => [$this]]); |
214 | 214 | } |
215 | 215 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @depends after-create |
218 | 218 | * @return Status |
219 | 219 | */ |
220 | - public function newStatus () { |
|
220 | + public function newStatus() { |
|
221 | 221 | return $this->factory(Status::class); |
222 | 222 | } |
223 | 223 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @depends after-create |
228 | 228 | * @return Task |
229 | 229 | */ |
230 | - public function newTask () { |
|
230 | + public function newTask() { |
|
231 | 231 | return $this->getSections()[0]->newTask(); |
232 | 232 | } |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param User $user |
237 | 237 | * @return $this |
238 | 238 | */ |
239 | - public function removeMember (User $user) { |
|
239 | + public function removeMember(User $user) { |
|
240 | 240 | return $this->removeMembers([$user]); |
241 | 241 | } |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param User[] $users |
246 | 246 | * @return $this |
247 | 247 | */ |
248 | - public function removeMembers (array $users) { |
|
248 | + public function removeMembers(array $users) { |
|
249 | 249 | $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]); |
250 | 250 | $this->_remove('members', $users); |
251 | 251 | return $this; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param null|Team $team |
257 | 257 | * @return $this |
258 | 258 | */ |
259 | - public function setTeam (?Team $team) { |
|
259 | + public function setTeam(?Team $team) { |
|
260 | 260 | assert(!$this->hasGid()); |
261 | 261 | if ($team and !$this->hasWorkspace()) { |
262 | 262 | $this->setWorkspace($team->getOrganization()); |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return Cache |
54 | 54 | */ |
55 | - public static function getCache () { |
|
55 | + public static function getCache() { |
|
56 | 56 | return static::$cache ?? static::$cache = new Cache(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @return Api |
61 | 61 | */ |
62 | - public static function getDefault () { |
|
62 | + public static function getDefault() { |
|
63 | 63 | return self::$default; |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return LoggerInterface |
68 | 68 | */ |
69 | - public static function getLogger () { |
|
69 | + public static function getLogger() { |
|
70 | 70 | return static::$logger ?? static::$logger = new class implements LoggerInterface { |
71 | 71 | |
72 | - public function log (string $info, string $path, ?array $payload): void { |
|
72 | + public function log(string $info, string $path, ?array $payload): void { |
|
73 | 73 | // stub |
74 | 74 | } |
75 | 75 | |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * @param Cache $cache |
81 | 81 | */ |
82 | - public static function setCache (Cache $cache) { |
|
82 | + public static function setCache(Cache $cache) { |
|
83 | 83 | static::$cache = $cache; |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | 87 | * @param Api $default |
88 | 88 | */ |
89 | - public static function setDefault (Api $default) { |
|
89 | + public static function setDefault(Api $default) { |
|
90 | 90 | self::$default = $default; |
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param LoggerInterface $logger |
95 | 95 | */ |
96 | - public static function setLogger (LoggerInterface $logger) { |
|
96 | + public static function setLogger(LoggerInterface $logger) { |
|
97 | 97 | static::$logger = $logger; |
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param string $token |
102 | 102 | */ |
103 | - public function __construct (string $token) { |
|
103 | + public function __construct(string $token) { |
|
104 | 104 | $this->token = $token; |
105 | 105 | if (!static::$default) { |
106 | 106 | static::$default = $this; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param string $path |
114 | 114 | */ |
115 | - public function delete (string $path): void { |
|
115 | + public function delete(string $path): void { |
|
116 | 116 | $this->exec('DELETE', $path); |
117 | 117 | } |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return null|array |
124 | 124 | * @internal |
125 | 125 | */ |
126 | - protected function exec (string $method, string $path, array $opts = null) { |
|
126 | + protected function exec(string $method, string $path, array $opts = null) { |
|
127 | 127 | $ch = curl_init(); |
128 | 128 | curl_setopt_array($ch, [ |
129 | 129 | CURLOPT_CUSTOMREQUEST => $method, |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param array $data |
175 | 175 | * @return mixed |
176 | 176 | */ |
177 | - public function factory (string $class, $caller, array $data = []) { |
|
177 | + public function factory(string $class, $caller, array $data = []) { |
|
178 | 178 | return new $class($caller, $data); |
179 | 179 | } |
180 | 180 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param array $options |
187 | 187 | * @return null|array |
188 | 188 | */ |
189 | - public function get (string $path, array $query = [], array $options = []) { |
|
189 | + public function get(string $path, array $query = [], array $options = []) { |
|
190 | 190 | foreach ($options as $name => $value) { |
191 | 191 | $query["opt_{$name}"] = $value; |
192 | 192 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param string $gid |
201 | 201 | * @return null|Attachment |
202 | 202 | */ |
203 | - public function getAttachment (string $gid) { |
|
203 | + public function getAttachment(string $gid) { |
|
204 | 204 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
205 | 205 | } |
206 | 206 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $gid |
211 | 211 | * @return null|CustomField |
212 | 212 | */ |
213 | - public function getCustomField (string $gid) { |
|
213 | + public function getCustomField(string $gid) { |
|
214 | 214 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return User |
221 | 221 | */ |
222 | - public function getMe () { |
|
222 | + public function getMe() { |
|
223 | 223 | return $this->getUser('me'); |
224 | 224 | } |
225 | 225 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param array $query |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - protected function getPath (string $path, array $query): string { |
|
233 | + protected function getPath(string $path, array $query): string { |
|
234 | 234 | return $query ? $path . '?' . http_build_query($query) : $path; |
235 | 235 | } |
236 | 236 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $gid |
241 | 241 | * @return null|Portfolio |
242 | 242 | */ |
243 | - public function getPortfolio (string $gid) { |
|
243 | + public function getPortfolio(string $gid) { |
|
244 | 244 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
245 | 245 | } |
246 | 246 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param string $gid |
251 | 251 | * @return null|Project |
252 | 252 | */ |
253 | - public function getProject (string $gid) { |
|
253 | + public function getProject(string $gid) { |
|
254 | 254 | return $this->load(Project::class, $this, "projects/{$gid}"); |
255 | 255 | } |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param string $gid |
261 | 261 | * @return null|Section |
262 | 262 | */ |
263 | - public function getSection (string $gid) { |
|
263 | + public function getSection(string $gid) { |
|
264 | 264 | return $this->load(Section::class, $this, "sections/{$gid}"); |
265 | 265 | } |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param string $gid |
271 | 271 | * @return null|Story |
272 | 272 | */ |
273 | - public function getStory (string $gid) { |
|
273 | + public function getStory(string $gid) { |
|
274 | 274 | return $this->load(Story::class, $this, "stories/{$gid}"); |
275 | 275 | } |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param string $gid |
281 | 281 | * @return null|Tag |
282 | 282 | */ |
283 | - public function getTag (string $gid) { |
|
283 | + public function getTag(string $gid) { |
|
284 | 284 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
285 | 285 | } |
286 | 286 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param string $gid |
291 | 291 | * @return null|Task |
292 | 292 | */ |
293 | - public function getTask (string $gid) { |
|
293 | + public function getTask(string $gid) { |
|
294 | 294 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
295 | 295 | } |
296 | 296 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string $gid |
301 | 301 | * @return null|Team |
302 | 302 | */ |
303 | - public function getTeam (string $gid) { |
|
303 | + public function getTeam(string $gid) { |
|
304 | 304 | return $this->load(Team::class, $this, "teams/{$gid}"); |
305 | 305 | } |
306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param string $gid |
311 | 311 | * @return null|User |
312 | 312 | */ |
313 | - public function getUser (string $gid) { |
|
313 | + public function getUser(string $gid) { |
|
314 | 314 | return $this->load(User::class, $this, "users/{$gid}"); |
315 | 315 | } |
316 | 316 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param array $data |
323 | 323 | * @return ProjectEvent|TaskEvent|StoryEvent |
324 | 324 | */ |
325 | - public function getWebhookEvent (array $data) { |
|
325 | + public function getWebhookEvent(array $data) { |
|
326 | 326 | static $classes = [ |
327 | 327 | Project::TYPE => ProjectEvent::class, |
328 | 328 | Task::TYPE => TaskEvent::class, |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @param string $gid |
336 | 336 | * @return null|Workspace |
337 | 337 | */ |
338 | - public function getWorkspace (string $gid) { |
|
338 | + public function getWorkspace(string $gid) { |
|
339 | 339 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
340 | 340 | } |
341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param string $name |
344 | 344 | * @return null|Workspace |
345 | 345 | */ |
346 | - public function getWorkspaceByName (string $name) { |
|
346 | + public function getWorkspaceByName(string $name) { |
|
347 | 347 | foreach ($this->getMe()->getWorkspaces() as $workspace) { |
348 | 348 | if ($workspace->getName() === $name) { |
349 | 349 | return $workspace; |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | * @param string $json |
357 | 357 | * @return null|array |
358 | 358 | */ |
359 | - protected function jsonDecode (string $json) { |
|
360 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
359 | + protected function jsonDecode(string $json) { |
|
360 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * @param array $data |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - protected function jsonEncode (array $data): string { |
|
368 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
367 | + protected function jsonEncode(array $data): string { |
|
368 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param array $query |
380 | 380 | * @return null|mixed|AbstractEntity |
381 | 381 | */ |
382 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
382 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
383 | 383 | $key = $this->getPath($path, $query); |
384 | 384 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
385 | 385 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param int $pages If positive, stops after this many pages have been fetched. |
400 | 400 | * @return array|AbstractEntity[] |
401 | 401 | */ |
402 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
402 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
403 | 403 | $query['opt_expand'] = 'this'; |
404 | 404 | $query += ['limit' => 100]; |
405 | 405 | $path = $this->getPath($path, $query); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param array $options |
426 | 426 | * @return null|array |
427 | 427 | */ |
428 | - public function post (string $path, array $data = [], array $options = []) { |
|
428 | + public function post(string $path, array $data = [], array $options = []) { |
|
429 | 429 | $response = $this->exec('POST', $path, [ |
430 | 430 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
431 | 431 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param array $options |
442 | 442 | * @return null|array |
443 | 443 | */ |
444 | - public function put (string $path, array $data = [], array $options = []) { |
|
444 | + public function put(string $path, array $data = [], array $options = []) { |
|
445 | 445 | $response = $this->exec('PUT', $path, [ |
446 | 446 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
447 | 447 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param null|string $token |
461 | 461 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
462 | 462 | */ |
463 | - public function sync ($entity, &$token) { |
|
463 | + public function sync($entity, &$token) { |
|
464 | 464 | try { |
465 | 465 | $response = $this->exec('GET', $this->getPath('events', [ |
466 | 466 | 'resource' => $entity->getGid(), |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @param string $file |
493 | 493 | * @return null|array |
494 | 494 | */ |
495 | - public function upload (string $path, string $file) { |
|
495 | + public function upload(string $path, string $file) { |
|
496 | 496 | $response = $this->exec('POST', $path, [ |
497 | 497 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
498 | 498 | ]); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param Api|Data $caller |
31 | 31 | * @param array $data |
32 | 32 | */ |
33 | - public function __construct ($caller, array $data = []) { |
|
33 | + public function __construct($caller, array $data = []) { |
|
34 | 34 | $this->api = $caller instanceof self ? $caller->api : $caller; |
35 | 35 | $this->_setData($data); |
36 | 36 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param array $args |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function __call (string $method, array $args) { |
|
49 | + public function __call(string $method, array $args) { |
|
50 | 50 | static $cache = []; |
51 | - if (!$call =& $cache[$method]) { |
|
51 | + if (!$call = & $cache[$method]) { |
|
52 | 52 | preg_match('/^(get|has|is|set)(.+)$/', $method, $call); |
53 | 53 | $call[1] = '_' . $call[1]; |
54 | 54 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | return $this->{$call[1]}($call[2], ...$args); |
59 | 59 | } |
60 | 60 | |
61 | - public function __debugInfo (): array { |
|
61 | + public function __debugInfo(): array { |
|
62 | 62 | return $this->data; |
63 | 63 | } |
64 | 64 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param string $key |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - protected function _get (string $key) { |
|
73 | + protected function _get(string $key) { |
|
74 | 74 | return $this->data[$key] ?? null; |
75 | 75 | } |
76 | 76 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function _getMap (): array { |
|
85 | + protected function _getMap(): array { |
|
86 | 86 | return []; |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param null|self|array $value |
92 | 92 | * @return null|Data|Data[] |
93 | 93 | */ |
94 | - protected function _getMapped ($class, $value) { |
|
94 | + protected function _getMapped($class, $value) { |
|
95 | 95 | // use empty|Data|Data[] as-is |
96 | 96 | if (!$value or $value instanceof self or current($value) instanceof self) { |
97 | 97 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $key |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - protected function _has (string $key): bool { |
|
132 | + protected function _has(string $key): bool { |
|
133 | 133 | $value = $this->_get($key); |
134 | 134 | if (isset($value)) { |
135 | 135 | if (is_countable($value)) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param string $key |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - protected function _is (string $key): bool { |
|
155 | + protected function _is(string $key): bool { |
|
156 | 156 | return !empty($this->_get($key)); |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param mixed $value |
166 | 166 | * @return $this |
167 | 167 | */ |
168 | - protected function _set (string $key, $value) { |
|
168 | + protected function _set(string $key, $value) { |
|
169 | 169 | $this->data[$key] = $value; |
170 | 170 | $this->diff[$key] = true; |
171 | 171 | return $this; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $data |
178 | 178 | * @return $this |
179 | 179 | */ |
180 | - protected function _setData (array $data) { |
|
180 | + protected function _setData(array $data) { |
|
181 | 181 | $map = $this->_getMap(); |
182 | 182 | /** @var null|self|array $value */ |
183 | 183 | foreach (array_intersect_key($data, $map) as $key => $value) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param array $data |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - final protected function factory (string $class, array $data = []) { |
|
198 | + final protected function factory(string $class, array $data = []) { |
|
199 | 199 | return $this->api->factory($class, $this, $data); |
200 | 200 | } |
201 | 201 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array |
206 | 206 | */ |
207 | - public function getDiff (): array { |
|
207 | + public function getDiff(): array { |
|
208 | 208 | $convert = function($each) use (&$convert) { |
209 | 209 | // convert existing entities to gids |
210 | 210 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return bool |
231 | 231 | */ |
232 | - final public function isDiff (): bool { |
|
232 | + final public function isDiff(): bool { |
|
233 | 233 | return (bool)$this->diff; |
234 | 234 | } |
235 | 235 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @see toArray() |
238 | 238 | * @return array |
239 | 239 | */ |
240 | - public function jsonSerialize (): array { |
|
240 | + public function jsonSerialize(): array { |
|
241 | 241 | return $this->toArray(); |
242 | 242 | } |
243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param array $query |
252 | 252 | * @return null|mixed|AbstractEntity |
253 | 253 | */ |
254 | - final protected function load (string $class, string $path, array $query = []) { |
|
254 | + final protected function load(string $class, string $path, array $query = []) { |
|
255 | 255 | return $this->api->load($class, $this, $path, $query); |
256 | 256 | } |
257 | 257 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param int $pages |
267 | 267 | * @return array|AbstractEntity[] |
268 | 268 | */ |
269 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
269 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
270 | 270 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
271 | 271 | } |
272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public function serialize (): string { |
|
278 | + public function serialize(): string { |
|
279 | 279 | return serialize($this->toArray()); |
280 | 280 | } |
281 | 281 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - public function toArray (): array { |
|
287 | + public function toArray(): array { |
|
288 | 288 | if (!$this->api) { |
289 | 289 | return $this->data; |
290 | 290 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param $serialized |
310 | 310 | */ |
311 | - public function unserialize ($serialized): void { |
|
311 | + public function unserialize($serialized): void { |
|
312 | 312 | $this->api = Api::getDefault(); |
313 | 313 | $this->data = unserialize($serialized); |
314 | 314 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected $task; |
41 | 41 | |
42 | - public function __construct (Task $task, array $fields) { |
|
42 | + public function __construct(Task $task, array $fields) { |
|
43 | 43 | parent::__construct($task); |
44 | 44 | $this->task = $task; |
45 | 45 | foreach ($fields as $field) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @return int |
62 | 62 | */ |
63 | - public function count () { |
|
63 | + public function count() { |
|
64 | 64 | return count($this->data); |
65 | 65 | } |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $fieldName |
69 | 69 | * @return null|string |
70 | 70 | */ |
71 | - public function getGid (string $fieldName) { |
|
71 | + public function getGid(string $fieldName) { |
|
72 | 72 | return $this->gids[$fieldName] ?? null; |
73 | 73 | } |
74 | 74 | |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return string[] |
79 | 79 | */ |
80 | - public function getGids () { |
|
80 | + public function getGids() { |
|
81 | 81 | return $this->gids; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return Traversable |
86 | 86 | */ |
87 | - public function getIterator () { |
|
87 | + public function getIterator() { |
|
88 | 88 | return new ArrayIterator($this->data); |
89 | 89 | } |
90 | 90 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string $fieldGid |
93 | 93 | * @return null|string |
94 | 94 | */ |
95 | - public function getName (string $fieldGid): ?string { |
|
95 | + public function getName(string $fieldGid): ?string { |
|
96 | 96 | return array_search($fieldGid, $this->gids) ?: null; |
97 | 97 | } |
98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string[] |
103 | 103 | */ |
104 | - public function getNames () { |
|
104 | + public function getNames() { |
|
105 | 105 | return array_flip($this->gids); |
106 | 106 | } |
107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $optionName |
111 | 111 | * @return null|string |
112 | 112 | */ |
113 | - public function getOptionGid (string $enumGid, string $optionName) { |
|
113 | + public function getOptionGid(string $enumGid, string $optionName) { |
|
114 | 114 | return array_search($optionName, $this->optionNames[$enumGid]) ?: null; |
115 | 115 | } |
116 | 116 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param string $enumGid |
121 | 121 | * @return string[] |
122 | 122 | */ |
123 | - public function getOptionGids (string $enumGid) { |
|
123 | + public function getOptionGids(string $enumGid) { |
|
124 | 124 | return array_flip($this->optionNames[$enumGid]); |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $optionGid |
130 | 130 | * @return null|string |
131 | 131 | */ |
132 | - public function getOptionName (string $enumGid, string $optionGid): ?string { |
|
132 | + public function getOptionName(string $enumGid, string $optionGid): ?string { |
|
133 | 133 | return $this->optionNames[$enumGid][$optionGid] ?? null; |
134 | 134 | } |
135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $enumGid |
140 | 140 | * @return string[] |
141 | 141 | */ |
142 | - public function getOptionNames (string $enumGid) { |
|
142 | + public function getOptionNames(string $enumGid) { |
|
143 | 143 | return $this->optionNames[$enumGid]; |
144 | 144 | } |
145 | 145 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $fieldGid |
148 | 148 | * @return null|number|string |
149 | 149 | */ |
150 | - public function getValue (string $fieldGid) { |
|
150 | + public function getValue(string $fieldGid) { |
|
151 | 151 | return $this->data[$fieldGid] ?? null; |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $fieldGid |
156 | 156 | * @return bool |
157 | 157 | */ |
158 | - public function offsetExists ($fieldGid) { |
|
158 | + public function offsetExists($fieldGid) { |
|
159 | 159 | return array_key_exists($fieldGid, $this->data); |
160 | 160 | } |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $fieldGid |
164 | 164 | * @return null|number|string |
165 | 165 | */ |
166 | - public function offsetGet ($fieldGid) { |
|
166 | + public function offsetGet($fieldGid) { |
|
167 | 167 | return $this->getValue($fieldGid); |
168 | 168 | } |
169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $fieldGid |
172 | 172 | * @param null|number|string $value |
173 | 173 | */ |
174 | - public function offsetSet ($fieldGid, $value) { |
|
174 | + public function offsetSet($fieldGid, $value) { |
|
175 | 175 | $this->setValue($fieldGid, $value); |
176 | 176 | } |
177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $fieldGid |
182 | 182 | */ |
183 | - public function offsetUnset ($fieldGid) { |
|
183 | + public function offsetUnset($fieldGid) { |
|
184 | 184 | $this->setValue($fieldGid, null); |
185 | 185 | } |
186 | 186 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param null|number|string $value |
190 | 190 | * @return $this |
191 | 191 | */ |
192 | - public function setValue (string $fieldGid, $value) { |
|
192 | + public function setValue(string $fieldGid, $value) { |
|
193 | 193 | $this->data[$fieldGid] = $value; |
194 | 194 | $this->diff[$fieldGid] = true; |
195 | 195 | $this->task->diff['custom_fields'] = true; |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | const ASSIGN_TODAY = 'today'; |
75 | 75 | const ASSIGN_UPCOMING = 'upcoming'; |
76 | 76 | |
77 | - final public function __toString (): string { |
|
77 | + final public function __toString(): string { |
|
78 | 78 | return "tasks/{$this->getGid()}"; |
79 | 79 | } |
80 | 80 | |
81 | - final protected function _getDir (): string { |
|
81 | + final protected function _getDir(): string { |
|
82 | 82 | return 'tasks'; |
83 | 83 | } |
84 | 84 | |
85 | - protected function _getMap (): array { |
|
85 | + protected function _getMap(): array { |
|
86 | 86 | return [ |
87 | 87 | 'assignee' => User::class, |
88 | 88 | 'custom_fields' => CustomValues::class, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $file |
104 | 104 | * @return Attachment |
105 | 105 | */ |
106 | - public function addAttachment (string $file) { |
|
106 | + public function addAttachment(string $file) { |
|
107 | 107 | /** @var Attachment $attachment */ |
108 | 108 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
109 | 109 | return $attachment->upload($file); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $text |
117 | 117 | * @return Story |
118 | 118 | */ |
119 | - public function addComment (string $text) { |
|
119 | + public function addComment(string $text) { |
|
120 | 120 | return $this->newComment()->setText($text)->create(); |
121 | 121 | } |
122 | 122 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param Task[] $tasks |
128 | 128 | * @return $this |
129 | 129 | */ |
130 | - public function addDependencies (array $tasks) { |
|
130 | + public function addDependencies(array $tasks) { |
|
131 | 131 | $this->api->post("{$this}/addDependencies", ['dependents' => static::_getGids($tasks)]); |
132 | 132 | return $this; |
133 | 133 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param Task $task |
140 | 140 | * @return $this |
141 | 141 | */ |
142 | - public function addDependency (Task $task) { |
|
142 | + public function addDependency(Task $task) { |
|
143 | 143 | return $this->addDependencies([$task]); |
144 | 144 | } |
145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param Task $task |
151 | 151 | * @return $this |
152 | 152 | */ |
153 | - public function addDependent (Task $task) { |
|
153 | + public function addDependent(Task $task) { |
|
154 | 154 | return $this->addDependents([$task]); |
155 | 155 | } |
156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param Task[] $tasks |
162 | 162 | * @return $this |
163 | 163 | */ |
164 | - public function addDependents (array $tasks) { |
|
164 | + public function addDependents(array $tasks) { |
|
165 | 165 | $this->api->post("{$this}/addDependents", ['dependents' => static::_getGids($tasks)]); |
166 | 166 | return $this; |
167 | 167 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param User $user |
173 | 173 | * @return $this |
174 | 174 | */ |
175 | - public function addFollower (User $user) { |
|
175 | + public function addFollower(User $user) { |
|
176 | 176 | return $this->addFollowers([$user]); |
177 | 177 | } |
178 | 178 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param User[] $users |
183 | 183 | * @return $this |
184 | 184 | */ |
185 | - public function addFollowers (array $users) { |
|
185 | + public function addFollowers(array $users) { |
|
186 | 186 | if ($this->hasGid()) { |
187 | 187 | $this->api->post("{$this}/addFollowers", ['followers' => static::_getGids($users)]); |
188 | 188 | $this->_merge('followers', $users); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param Tag $tag |
200 | 200 | * @return $this |
201 | 201 | */ |
202 | - public function addTag (Tag $tag) { |
|
202 | + public function addTag(Tag $tag) { |
|
203 | 203 | if ($this->hasGid()) { |
204 | 204 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
205 | 205 | $this->_merge('tags', [$tag]); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param Section $section |
217 | 217 | * @return $this |
218 | 218 | */ |
219 | - public function addToProject (Section $section) { |
|
219 | + public function addToProject(Section $section) { |
|
220 | 220 | $project = $section->getProject(); |
221 | 221 | if ($this->hasGid()) { |
222 | 222 | $this->api->post("{$this}/addProject", [ |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param string $target |
251 | 251 | * @return TaskWebhook |
252 | 252 | */ |
253 | - public function addWebhook (string $target) { |
|
253 | + public function addWebhook(string $target) { |
|
254 | 254 | /** @var TaskWebhook $webhook */ |
255 | 255 | $webhook = $this->factory(TaskWebhook::class); |
256 | 256 | return $webhook->create($this, $target); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param string[] $include |
267 | 267 | * @return Job |
268 | 268 | */ |
269 | - public function duplicate (string $name, array $include) { |
|
269 | + public function duplicate(string $name, array $include) { |
|
270 | 270 | $remote = $this->api->post("{$this}/duplicate", [ |
271 | 271 | 'name' => $name, |
272 | 272 | 'include' => array_values($include) |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @depends after-create |
281 | 281 | * @return Attachment[] |
282 | 282 | */ |
283 | - public function getAttachments () { |
|
283 | + public function getAttachments() { |
|
284 | 284 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
285 | 285 | } |
286 | 286 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @depends after-create |
291 | 291 | * @return Story[] |
292 | 292 | */ |
293 | - public function getComments () { |
|
293 | + public function getComments() { |
|
294 | 294 | return array_values(array_filter($this->getStories(), function(Story $story) { |
295 | 295 | return $story->isComment(); |
296 | 296 | })); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @depends after-create |
303 | 303 | * @return Task[] |
304 | 304 | */ |
305 | - public function getDependencies () { |
|
305 | + public function getDependencies() { |
|
306 | 306 | return $this->loadAll(self::class, "{$this}/dependencies"); |
307 | 307 | } |
308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @depends after-create |
313 | 313 | * @return Task[] |
314 | 314 | */ |
315 | - public function getDependents () { |
|
315 | + public function getDependents() { |
|
316 | 316 | return $this->loadAll(self::class, "{$this}/dependents"); |
317 | 317 | } |
318 | 318 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param null|string $token |
324 | 324 | * @return TaskEvent[]|StoryEvent[] |
325 | 325 | */ |
326 | - public function getEvents (&$token) { |
|
326 | + public function getEvents(&$token) { |
|
327 | 327 | return $this->api->sync($this, $token); |
328 | 328 | } |
329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @depends after-create |
334 | 334 | * @return Story[] |
335 | 335 | */ |
336 | - public function getStories () { |
|
336 | + public function getStories() { |
|
337 | 337 | return $this->loadAll(Story::class, "{$this}/stories"); |
338 | 338 | } |
339 | 339 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @depends after-create |
344 | 344 | * @return Task[] |
345 | 345 | */ |
346 | - public function getSubTasks () { |
|
346 | + public function getSubTasks() { |
|
347 | 347 | return $this->loadAll(self::class, "{$this}/subtasks"); |
348 | 348 | } |
349 | 349 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @depends after-create |
354 | 354 | * @return string |
355 | 355 | */ |
356 | - public function getUrl (): string { |
|
356 | + public function getUrl(): string { |
|
357 | 357 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
358 | 358 | } |
359 | 359 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @depends after-create |
364 | 364 | * @return TaskWebhook[] |
365 | 365 | */ |
366 | - public function getWebhooks () { |
|
366 | + public function getWebhooks() { |
|
367 | 367 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
368 | 368 | 'workspace' => $this->getWorkspace()->getGid(), |
369 | 369 | 'resource' => $this->getGid() |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /** |
374 | 374 | * @return bool |
375 | 375 | */ |
376 | - public function isRenderedAsSeparator (): bool { |
|
376 | + public function isRenderedAsSeparator(): bool { |
|
377 | 377 | return $this->_is('is_rendered_as_separator'); |
378 | 378 | } |
379 | 379 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @depends after-create |
384 | 384 | * @return Story |
385 | 385 | */ |
386 | - public function newComment () { |
|
386 | + public function newComment() { |
|
387 | 387 | /** @var Story $comment */ |
388 | 388 | $comment = $this->factory(Story::class, [ |
389 | 389 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @depends after-create |
398 | 398 | * @return Task |
399 | 399 | */ |
400 | - public function newSubTask () { |
|
400 | + public function newSubTask() { |
|
401 | 401 | /** @var Task $sub */ |
402 | 402 | $sub = $this->factory(self::class); |
403 | 403 | return $sub->setParent($this); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param Task[] $tasks |
411 | 411 | * @return $this |
412 | 412 | */ |
413 | - public function removeDependencies (array $tasks) { |
|
413 | + public function removeDependencies(array $tasks) { |
|
414 | 414 | $this->api->post("{$this}/removeDependencies", ['dependencies' => static::_getGids($tasks)]); |
415 | 415 | return $this; |
416 | 416 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param Task $task |
423 | 423 | * @return $this |
424 | 424 | */ |
425 | - public function removeDependency (Task $task) { |
|
425 | + public function removeDependency(Task $task) { |
|
426 | 426 | return $this->removeDependencies([$task]); |
427 | 427 | } |
428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @param Task $task |
434 | 434 | * @return $this |
435 | 435 | */ |
436 | - public function removeDependent (Task $task) { |
|
436 | + public function removeDependent(Task $task) { |
|
437 | 437 | return $this->removeDependents([$task]); |
438 | 438 | } |
439 | 439 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param Task[] $tasks |
445 | 445 | * @return $this |
446 | 446 | */ |
447 | - public function removeDependents (array $tasks) { |
|
447 | + public function removeDependents(array $tasks) { |
|
448 | 448 | $this->api->post("{$this}/removeDependents", ['dependents' => static::_getGids($tasks)]); |
449 | 449 | return $this; |
450 | 450 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * @param User $user |
456 | 456 | * @return $this |
457 | 457 | */ |
458 | - public function removeFollower (User $user) { |
|
458 | + public function removeFollower(User $user) { |
|
459 | 459 | return $this->removeFollowers([$user]); |
460 | 460 | } |
461 | 461 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @param User[] $users |
466 | 466 | * @return $this |
467 | 467 | */ |
468 | - public function removeFollowers (array $users) { |
|
468 | + public function removeFollowers(array $users) { |
|
469 | 469 | if ($this->hasGid()) { |
470 | 470 | $this->api->post("{$this}/removeFollowers", ['followers' => static::_getGids($users)]); |
471 | 471 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param Project $project |
480 | 480 | * @return $this |
481 | 481 | */ |
482 | - public function removeFromProject (Project $project) { |
|
482 | + public function removeFromProject(Project $project) { |
|
483 | 483 | $gid = $project->getGid(); |
484 | 484 | if ($this->hasGid()) { |
485 | 485 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @param Tag $tag |
499 | 499 | * @return $this |
500 | 500 | */ |
501 | - public function removeTag (Tag $tag) { |
|
501 | + public function removeTag(Tag $tag) { |
|
502 | 502 | if ($this->hasGid()) { |
503 | 503 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
504 | 504 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @param null|Task $parent |
513 | 513 | * @return $this |
514 | 514 | */ |
515 | - public function setParent (?self $parent) { |
|
515 | + public function setParent(?self $parent) { |
|
516 | 516 | if ($this->hasGid()) { |
517 | 517 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
518 | 518 | $this->data['parent'] = $parent; |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | * @param bool $flag |
528 | 528 | * @return $this |
529 | 529 | */ |
530 | - public function setRenderedAsSeparator (bool $flag) { |
|
530 | + public function setRenderedAsSeparator(bool $flag) { |
|
531 | 531 | return $this->_set('is_rendered_as_separator', $flag); |
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
535 | 535 | * @return $this |
536 | 536 | */ |
537 | - public function update () { |
|
537 | + public function update() { |
|
538 | 538 | $this->_update(); |
539 | 539 | if ($this->hasCustomFields()) { |
540 | 540 | $this->getCustomFields()->diff = []; |