@@ -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,28 +123,28 @@ 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 | |
| 130 | 130 | /** |
| 131 | 131 | * @return Project[] |
| 132 | 132 | */ |
| 133 | - public function getProjects () { |
|
| 133 | + public function getProjects() { |
|
| 134 | 134 | return $this->loadAll(Project::class, 'projects', ['workspace' => $this->getGid()]); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @return Tag[] |
| 139 | 139 | */ |
| 140 | - public function getTags () { |
|
| 140 | + public function getTags() { |
|
| 141 | 141 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * @return Team[] |
| 146 | 146 | */ |
| 147 | - public function getTeams () { |
|
| 147 | + public function getTeams() { |
|
| 148 | 148 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param string $email |
| 153 | 153 | * @return null|User |
| 154 | 154 | */ |
| 155 | - public function getUserByEmail (string $email) { |
|
| 155 | + public function getUserByEmail(string $email) { |
|
| 156 | 156 | return $this->api->getCache()->get($email, $this, function() use ($email) { |
| 157 | 157 | foreach ($this->getUsers() as $user) { |
| 158 | 158 | if ($user->getEmail() === $email) { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * @return User[] |
| 168 | 168 | */ |
| 169 | - public function getUsers () { |
|
| 169 | + public function getUsers() { |
|
| 170 | 170 | return $this->loadAll(User::class, "{$this}/users"); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return ProjectWebhook[]|TaskWebhook[] |
| 177 | 177 | */ |
| 178 | - public function getWebhooks () { |
|
| 178 | + public function getWebhooks() { |
|
| 179 | 179 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 180 | 180 | return array_map(function(array $each) { |
| 181 | 181 | return $this->api->getCache()->get($each['gid'], $this, function() use ($each) { |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * @return bool |
| 193 | 193 | */ |
| 194 | - public function isOrganization (): bool { |
|
| 194 | + public function isOrganization(): bool { |
|
| 195 | 195 | return $this->_is('is_organization'); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return CustomField |
| 202 | 202 | */ |
| 203 | - public function newCustomField () { |
|
| 203 | + public function newCustomField() { |
|
| 204 | 204 | /** @var CustomField $field */ |
| 205 | 205 | $field = $this->factory(CustomField::class); |
| 206 | 206 | return $field->setWorkspace($this); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return Portfolio |
| 213 | 213 | */ |
| 214 | - public function newPortfolio () { |
|
| 214 | + public function newPortfolio() { |
|
| 215 | 215 | /** @var Portfolio $portfolio */ |
| 216 | 216 | $portfolio = $this->factory(Portfolio::class); |
| 217 | 217 | return $portfolio->setWorkspace($this); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return Project |
| 224 | 224 | */ |
| 225 | - public function newProject () { |
|
| 225 | + public function newProject() { |
|
| 226 | 226 | /** @var Project $project */ |
| 227 | 227 | $project = $this->factory(Project::class); |
| 228 | 228 | return $project->setWorkspace($this); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return Tag |
| 235 | 235 | */ |
| 236 | - public function newTag () { |
|
| 236 | + public function newTag() { |
|
| 237 | 237 | /** @var Tag $tag */ |
| 238 | 238 | $tag = $this->factory(Tag::class); |
| 239 | 239 | return $tag->setWorkspace($this); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return Task |
| 246 | 246 | */ |
| 247 | - public function newTask () { |
|
| 247 | + public function newTask() { |
|
| 248 | 248 | /** @var Task $task */ |
| 249 | 249 | $task = $this->factory(Task::class); |
| 250 | 250 | return $task->setWorkspace($this); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * @param string $token |
| 42 | 42 | */ |
| 43 | - public function __construct (string $token) { |
|
| 43 | + public function __construct(string $token) { |
|
| 44 | 44 | $this->token = $token; |
| 45 | 45 | $this->cache = new Cache(); |
| 46 | 46 | $this->logger = new Logger(); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param string $path |
| 53 | 53 | */ |
| 54 | - public function delete (string $path): void { |
|
| 54 | + public function delete(string $path): void { |
|
| 55 | 55 | $this->exec('DELETE', $path); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @return null|array |
| 63 | 63 | * @internal |
| 64 | 64 | */ |
| 65 | - protected function exec (string $method, string $path, array $opts = null) { |
|
| 65 | + protected function exec(string $method, string $path, array $opts = null) { |
|
| 66 | 66 | $ch = curl_init(); |
| 67 | 67 | curl_setopt_array($ch, [ |
| 68 | 68 | CURLOPT_CUSTOMREQUEST => $method, |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param array $data |
| 114 | 114 | * @return mixed |
| 115 | 115 | */ |
| 116 | - public function factory (string $class, $caller, array $data = []) { |
|
| 116 | + public function factory(string $class, $caller, array $data = []) { |
|
| 117 | 117 | return new $class($caller, $data); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param array $options |
| 126 | 126 | * @return null|array |
| 127 | 127 | */ |
| 128 | - public function get (string $path, array $query = [], array $options = []) { |
|
| 128 | + public function get(string $path, array $query = [], array $options = []) { |
|
| 129 | 129 | foreach ($options as $name => $value) { |
| 130 | 130 | $query["opt_{$name}"] = $value; |
| 131 | 131 | } |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | * @param string $gid |
| 140 | 140 | * @return null|Attachment |
| 141 | 141 | */ |
| 142 | - public function getAttachment (string $gid) { |
|
| 142 | + public function getAttachment(string $gid) { |
|
| 143 | 143 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @return Cache |
| 148 | 148 | */ |
| 149 | - public function getCache () { |
|
| 149 | + public function getCache() { |
|
| 150 | 150 | return $this->cache; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | * @param string $gid |
| 157 | 157 | * @return null|CustomField |
| 158 | 158 | */ |
| 159 | - public function getCustomField (string $gid) { |
|
| 159 | + public function getCustomField(string $gid) { |
|
| 160 | 160 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * @return LoggerInterface |
| 165 | 165 | */ |
| 166 | - public function getLogger () { |
|
| 166 | + public function getLogger() { |
|
| 167 | 167 | return $this->logger; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return User |
| 174 | 174 | */ |
| 175 | - public function getMe () { |
|
| 175 | + public function getMe() { |
|
| 176 | 176 | return $this->getUser('me'); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param array $query |
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | - protected function getPath (string $path, array $query): string { |
|
| 186 | + protected function getPath(string $path, array $query): string { |
|
| 187 | 187 | return $query ? $path . '?' . http_build_query($query) : $path; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param string $gid |
| 194 | 194 | * @return null|Portfolio |
| 195 | 195 | */ |
| 196 | - public function getPortfolio (string $gid) { |
|
| 196 | + public function getPortfolio(string $gid) { |
|
| 197 | 197 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param string $gid |
| 204 | 204 | * @return null|Project |
| 205 | 205 | */ |
| 206 | - public function getProject (string $gid) { |
|
| 206 | + public function getProject(string $gid) { |
|
| 207 | 207 | return $this->load(Project::class, $this, "projects/{$gid}"); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @param string $gid |
| 214 | 214 | * @return null|Section |
| 215 | 215 | */ |
| 216 | - public function getSection (string $gid) { |
|
| 216 | + public function getSection(string $gid) { |
|
| 217 | 217 | return $this->load(Section::class, $this, "sections/{$gid}"); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @param string $gid |
| 224 | 224 | * @return null|Story |
| 225 | 225 | */ |
| 226 | - public function getStory (string $gid) { |
|
| 226 | + public function getStory(string $gid) { |
|
| 227 | 227 | return $this->load(Story::class, $this, "stories/{$gid}"); |
| 228 | 228 | } |
| 229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param string $gid |
| 234 | 234 | * @return null|Tag |
| 235 | 235 | */ |
| 236 | - public function getTag (string $gid) { |
|
| 236 | + public function getTag(string $gid) { |
|
| 237 | 237 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
| 238 | 238 | } |
| 239 | 239 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @param string $gid |
| 244 | 244 | * @return null|Task |
| 245 | 245 | */ |
| 246 | - public function getTask (string $gid) { |
|
| 246 | + public function getTask(string $gid) { |
|
| 247 | 247 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param string $gid |
| 254 | 254 | * @return null|Team |
| 255 | 255 | */ |
| 256 | - public function getTeam (string $gid) { |
|
| 256 | + public function getTeam(string $gid) { |
|
| 257 | 257 | return $this->load(Team::class, $this, "teams/{$gid}"); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string $gid |
| 264 | 264 | * @return null|User |
| 265 | 265 | */ |
| 266 | - public function getUser (string $gid) { |
|
| 266 | + public function getUser(string $gid) { |
|
| 267 | 267 | return $this->load(User::class, $this, "users/{$gid}"); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param array $data |
| 276 | 276 | * @return ProjectEvent|TaskEvent|StoryEvent |
| 277 | 277 | */ |
| 278 | - public function getWebhookEvent (array $data) { |
|
| 278 | + public function getWebhookEvent(array $data) { |
|
| 279 | 279 | static $classes = [ |
| 280 | 280 | Project::TYPE => ProjectEvent::class, |
| 281 | 281 | Task::TYPE => TaskEvent::class, |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @param string $gid |
| 289 | 289 | * @return null|Workspace |
| 290 | 290 | */ |
| 291 | - public function getWorkspace (string $gid) { |
|
| 291 | + public function getWorkspace(string $gid) { |
|
| 292 | 292 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param string $name |
| 297 | 297 | * @return null|Workspace |
| 298 | 298 | */ |
| 299 | - public function getWorkspaceByName (string $name) { |
|
| 299 | + public function getWorkspaceByName(string $name) { |
|
| 300 | 300 | foreach ($this->getMe()->getWorkspaces() as $workspace) { |
| 301 | 301 | if ($workspace->getName() === $name) { |
| 302 | 302 | return $workspace; |
@@ -309,16 +309,16 @@ discard block |
||
| 309 | 309 | * @param string $json |
| 310 | 310 | * @return null|array |
| 311 | 311 | */ |
| 312 | - protected function jsonDecode (string $json) { |
|
| 313 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 312 | + protected function jsonDecode(string $json) { |
|
| 313 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * @param array $data |
| 318 | 318 | * @return string |
| 319 | 319 | */ |
| 320 | - protected function jsonEncode (array $data): string { |
|
| 321 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 320 | + protected function jsonEncode(array $data): string { |
|
| 321 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @param array $query |
| 333 | 333 | * @return null|mixed|AbstractEntity |
| 334 | 334 | */ |
| 335 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
| 335 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
| 336 | 336 | $key = $this->getPath($path, $query); |
| 337 | 337 | return $this->cache->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 338 | 338 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * @param int $pages If positive, stops after this many pages have been fetched. |
| 353 | 353 | * @return array|AbstractEntity[] |
| 354 | 354 | */ |
| 355 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 355 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 356 | 356 | $query['opt_expand'] = 'this'; |
| 357 | 357 | $query += ['limit' => 100]; |
| 358 | 358 | $path = $this->getPath($path, $query); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param array $options |
| 379 | 379 | * @return null|array |
| 380 | 380 | */ |
| 381 | - public function post (string $path, array $data = [], array $options = []) { |
|
| 381 | + public function post(string $path, array $data = [], array $options = []) { |
|
| 382 | 382 | $response = $this->exec('POST', $path, [ |
| 383 | 383 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 384 | 384 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | * @param array $options |
| 395 | 395 | * @return null|array |
| 396 | 396 | */ |
| 397 | - public function put (string $path, array $data = [], array $options = []) { |
|
| 397 | + public function put(string $path, array $data = [], array $options = []) { |
|
| 398 | 398 | $response = $this->exec('PUT', $path, [ |
| 399 | 399 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 400 | 400 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param Cache $cache |
| 407 | 407 | * @return $this |
| 408 | 408 | */ |
| 409 | - public function setCache (Cache $cache) { |
|
| 409 | + public function setCache(Cache $cache) { |
|
| 410 | 410 | $this->cache = $cache; |
| 411 | 411 | return $this; |
| 412 | 412 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @param LoggerInterface $logger |
| 416 | 416 | * @return $this |
| 417 | 417 | */ |
| 418 | - public function setLogger (LoggerInterface $logger) { |
|
| 418 | + public function setLogger(LoggerInterface $logger) { |
|
| 419 | 419 | $this->logger = $logger; |
| 420 | 420 | return $this; |
| 421 | 421 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @param string $token |
| 430 | 430 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
| 431 | 431 | */ |
| 432 | - public function sync ($entity, &$token) { |
|
| 432 | + public function sync($entity, &$token) { |
|
| 433 | 433 | try { |
| 434 | 434 | $response = $this->exec('GET', $this->getPath('events', [ |
| 435 | 435 | 'resource' => $entity->getGid(), |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * @param string $file |
| 462 | 462 | * @return null|array |
| 463 | 463 | */ |
| 464 | - public function upload (string $path, string $file) { |
|
| 464 | + public function upload(string $path, string $file) { |
|
| 465 | 465 | $response = $this->exec('POST', $path, [ |
| 466 | 466 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 467 | 467 | ]); |