@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param Api $api |
37 | 37 | * @param PSR16 $cache |
38 | 38 | */ |
39 | - public function __construct (Api $api, PSR16 $cache) { |
|
39 | + public function __construct(Api $api, PSR16 $cache) { |
|
40 | 40 | $this->api = $api; |
41 | 41 | $this->cache = $cache; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param AbstractEntity $entity |
46 | 46 | * @throws InvalidArgumentException |
47 | 47 | */ |
48 | - public function add (AbstractEntity $entity): void { |
|
48 | + public function add(AbstractEntity $entity): void { |
|
49 | 49 | if ($gid = $entity->getGid() and !$entity->isDiff()) { |
50 | 50 | parent::add($entity); |
51 | 51 | foreach ($this->getKeys($entity) as $key) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - public function get (string $key, $caller, Closure $factory) { |
|
60 | + public function get(string $key, $caller, Closure $factory) { |
|
61 | 61 | return parent::get($key, $caller, function($caller) use ($key, $factory) { |
62 | 62 | /** @var null|string|AbstractEntity $entity */ |
63 | 63 | if ($entity = $this->cache->get($key)) { // hit? |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param Api|Data $caller |
102 | 102 | * @return AbstractEntity |
103 | 103 | */ |
104 | - protected function hydrate (AbstractEntity $proto, $caller) { |
|
104 | + protected function hydrate(AbstractEntity $proto, $caller) { |
|
105 | 105 | return $this->api->factory(get_class($proto), $caller, $proto->toArray()); |
106 | 106 | } |
107 | 107 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param AbstractEntity $entity |
110 | 110 | * @throws InvalidArgumentException |
111 | 111 | */ |
112 | - public function remove (AbstractEntity $entity): void { |
|
112 | + public function remove(AbstractEntity $entity): void { |
|
113 | 113 | parent::remove($entity); |
114 | 114 | $this->cache->deleteMultiple($this->getKeys($entity)); |
115 | 115 | } |
@@ -49,21 +49,21 @@ |
||
49 | 49 | /** |
50 | 50 | * @return Api |
51 | 51 | */ |
52 | - final public static function getApi () { |
|
52 | + final public static function getApi() { |
|
53 | 53 | return static::getFacadeRoot(); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public static function getFacadeAccessor () { |
|
59 | + public static function getFacadeAccessor() { |
|
60 | 60 | return AsanaServiceProvider::NAME; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @return Api |
65 | 65 | */ |
66 | - public static function getFacadeRoot () { |
|
66 | + public static function getFacadeRoot() { |
|
67 | 67 | return parent::getFacadeRoot(); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -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); |
@@ -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']); |
@@ -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, ?string &$token) { |
|
463 | + public function sync($entity, ?string &$token) { |
|
464 | 464 | try { |
465 | 465 | $response = $this->exec('GET', $this->getPath('events', [ |
466 | 466 | 'resource' => $entity->getGid(), |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @param string $file |
496 | 496 | * @return null|array |
497 | 497 | */ |
498 | - public function upload (string $path, string $file) { |
|
498 | + public function upload(string $path, string $file) { |
|
499 | 499 | $response = $this->exec('POST', $path, [ |
500 | 500 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
501 | 501 | ]); |
@@ -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 $enumGid |
69 | 69 | * @return null|string |
70 | 70 | */ |
71 | - public function getCurrentOptionName (string $enumGid): ?string { |
|
71 | + public function getCurrentOptionName(string $enumGid): ?string { |
|
72 | 72 | return $this->optionNames[$enumGid][$this[$enumGid]] ?? null; |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string $fieldName |
77 | 77 | * @return null|string |
78 | 78 | */ |
79 | - public function getGid (string $fieldName) { |
|
79 | + public function getGid(string $fieldName) { |
|
80 | 80 | return $this->gids[$fieldName] ?? null; |
81 | 81 | } |
82 | 82 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return string[] |
87 | 87 | */ |
88 | - public function getGids () { |
|
88 | + public function getGids() { |
|
89 | 89 | return $this->gids; |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return Traversable |
94 | 94 | */ |
95 | - public function getIterator () { |
|
95 | + public function getIterator() { |
|
96 | 96 | return new ArrayIterator($this->data); |
97 | 97 | } |
98 | 98 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $fieldGid |
101 | 101 | * @return null|string |
102 | 102 | */ |
103 | - public function getName (string $fieldGid): ?string { |
|
103 | + public function getName(string $fieldGid): ?string { |
|
104 | 104 | return array_search($fieldGid, $this->gids) ?: null; |
105 | 105 | } |
106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string[] |
111 | 111 | */ |
112 | - public function getNames () { |
|
112 | + public function getNames() { |
|
113 | 113 | return array_flip($this->gids); |
114 | 114 | } |
115 | 115 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param string $optionName |
119 | 119 | * @return null|string |
120 | 120 | */ |
121 | - public function getOptionGid (string $enumGid, string $optionName) { |
|
121 | + public function getOptionGid(string $enumGid, string $optionName) { |
|
122 | 122 | return array_search($optionName, $this->optionNames[$enumGid]) ?: null; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $enumGid |
129 | 129 | * @return string[] |
130 | 130 | */ |
131 | - public function getOptionGids (string $enumGid) { |
|
131 | + public function getOptionGids(string $enumGid) { |
|
132 | 132 | return array_flip($this->optionNames[$enumGid]); |
133 | 133 | } |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $optionGid |
138 | 138 | * @return null|string |
139 | 139 | */ |
140 | - public function getOptionName (string $enumGid, string $optionGid): ?string { |
|
140 | + public function getOptionName(string $enumGid, string $optionGid): ?string { |
|
141 | 141 | return $this->optionNames[$enumGid][$optionGid] ?? null; |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $enumGid |
148 | 148 | * @return string[] |
149 | 149 | */ |
150 | - public function getOptionNames (string $enumGid) { |
|
150 | + public function getOptionNames(string $enumGid) { |
|
151 | 151 | return $this->optionNames[$enumGid]; |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $fieldGid |
156 | 156 | * @return null|number|string |
157 | 157 | */ |
158 | - public function getValue (string $fieldGid) { |
|
158 | + public function getValue(string $fieldGid) { |
|
159 | 159 | return $this->data[$fieldGid] ?? null; |
160 | 160 | } |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $fieldGid |
164 | 164 | * @return bool |
165 | 165 | */ |
166 | - public function offsetExists ($fieldGid) { |
|
166 | + public function offsetExists($fieldGid) { |
|
167 | 167 | return array_key_exists($fieldGid, $this->data); |
168 | 168 | } |
169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $fieldGid |
172 | 172 | * @return null|number|string |
173 | 173 | */ |
174 | - public function offsetGet ($fieldGid) { |
|
174 | + public function offsetGet($fieldGid) { |
|
175 | 175 | return $this->getValue($fieldGid); |
176 | 176 | } |
177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param string $fieldGid |
180 | 180 | * @param null|number|string $value |
181 | 181 | */ |
182 | - public function offsetSet ($fieldGid, $value) { |
|
182 | + public function offsetSet($fieldGid, $value) { |
|
183 | 183 | $this->setValue($fieldGid, $value); |
184 | 184 | } |
185 | 185 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @param string $fieldGid |
190 | 190 | */ |
191 | - public function offsetUnset ($fieldGid) { |
|
191 | + public function offsetUnset($fieldGid) { |
|
192 | 192 | $this->setValue($fieldGid, null); |
193 | 193 | } |
194 | 194 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param null|number|string $value |
198 | 198 | * @return $this |
199 | 199 | */ |
200 | - public function setValue (string $fieldGid, $value) { |
|
200 | + public function setValue(string $fieldGid, $value) { |
|
201 | 201 | $this->data[$fieldGid] = $value; |
202 | 202 | $this->diff[$fieldGid] = true; |
203 | 203 | $this->task->diff['custom_fields'] = true; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $task; |
26 | 26 | |
27 | - public function __construct (Task $task, array $data = []) { |
|
27 | + public function __construct(Task $task, array $data = []) { |
|
28 | 28 | parent::__construct($task, $data); |
29 | 29 | $this->task = $task; |
30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param mixed $value |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - protected function _set (string $key, $value) { |
|
39 | + protected function _set(string $key, $value) { |
|
40 | 40 | $this->task->diff['external'] = true; |
41 | 41 | return parent::_set($key, $value); |
42 | 42 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 'new_task' => Task::class |
34 | 34 | ]; |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "jobs/{$this->getGid()}"; |
38 | 38 | } |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function isActive (): bool { |
|
45 | + public function isActive(): bool { |
|
46 | 46 | return $this->getStatus() === self::STATUS_ACTIVE; |
47 | 47 | } |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function isDone (): bool { |
|
54 | + public function isDone(): bool { |
|
55 | 55 | return $this->isSuccessful() or $this->isFailed(); |
56 | 56 | } |
57 | 57 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function isFailed (): bool { |
|
63 | + public function isFailed(): bool { |
|
64 | 64 | return $this->getStatus() === self::STATUS_FAIL; |
65 | 65 | } |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return bool |
71 | 71 | */ |
72 | - public function isQueued (): bool { |
|
72 | + public function isQueued(): bool { |
|
73 | 73 | return $this->getStatus() === self::STATUS_QUEUED; |
74 | 74 | } |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public function isSuccessful (): bool { |
|
81 | + public function isSuccessful(): bool { |
|
82 | 82 | return $this->getStatus() === self::STATUS_SUCCESS; |
83 | 83 | } |
84 | 84 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return $this |
89 | 89 | */ |
90 | - public function wait () { |
|
90 | + public function wait() { |
|
91 | 91 | while (!$this->isDone()) { |
92 | 92 | sleep(3); |
93 | 93 | $this->reload(); |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | 'workspace' => Workspace::class |
31 | 31 | ]; |
32 | 32 | |
33 | - final public function __toString (): string { |
|
33 | + final public function __toString(): string { |
|
34 | 34 | return "user_task_lists/{$this->getGid()}"; |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @return Task[] |
39 | 39 | */ |
40 | - public function getIncompleteTasks () { |
|
40 | + public function getIncompleteTasks() { |
|
41 | 41 | return $this->loadAll(Task::class, "{$this}/tasks", ['completed_since' => 'now']); |
42 | 42 | } |
43 | 43 | |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return ArrayIterator|Task[] |
48 | 48 | */ |
49 | - public function getIterator () { |
|
49 | + public function getIterator() { |
|
50 | 50 | return new ArrayIterator($this->getTasks()); |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @return Task[] |
55 | 55 | */ |
56 | - public function getTasks () { |
|
56 | + public function getTasks() { |
|
57 | 57 | return $this->loadAll(Task::class, "{$this}/tasks"); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |