@@ -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 | /** @var OrganizationExport $export */ |
| 40 | 40 | $export = $this->factory(OrganizationExport::class); |
| 41 | 41 | return $export->create($this); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param int $limit 1-100 |
| 53 | 53 | * @return array|AbstractEntity[] |
| 54 | 54 | */ |
| 55 | - protected function find (string $class, string $resourceType, string $text, int $limit = 20) { |
|
| 55 | + protected function find(string $class, string $resourceType, string $text, int $limit = 20) { |
|
| 56 | 56 | return $this->loadAll($class, "{$this}/typeahead", [ |
| 57 | 57 | 'resource_type' => $resourceType, |
| 58 | 58 | 'query' => $text, |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param int $limit 1-100 |
| 68 | 68 | * @return CustomField[] |
| 69 | 69 | */ |
| 70 | - public function findCustomFields (string $text, int $limit = 20) { |
|
| 70 | + public function findCustomFields(string $text, int $limit = 20) { |
|
| 71 | 71 | return $this->find(CustomField::class, CustomField::TYPE, $text, $limit); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param int $limit 1-100 |
| 79 | 79 | * @return Portfolio[] |
| 80 | 80 | */ |
| 81 | - public function findPortfolios (string $text, int $limit = 20) { |
|
| 81 | + public function findPortfolios(string $text, int $limit = 20) { |
|
| 82 | 82 | return $this->find(Portfolio::class, Portfolio::TYPE, $text, $limit); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param int $limit 1-100 |
| 90 | 90 | * @return Project[] |
| 91 | 91 | */ |
| 92 | - public function findProjects (string $text, int $limit = 20) { |
|
| 92 | + public function findProjects(string $text, int $limit = 20) { |
|
| 93 | 93 | return $this->find(Project::class, Project::TYPE, $text, $limit); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param int $limit 1-100 |
| 101 | 101 | * @return Tag[] |
| 102 | 102 | */ |
| 103 | - public function findTags (string $text, int $limit = 20) { |
|
| 103 | + public function findTags(string $text, int $limit = 20) { |
|
| 104 | 104 | return $this->find(Tag::class, Tag::TYPE, $text, $limit); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param int $limit 1-100 |
| 112 | 112 | * @return Task[] |
| 113 | 113 | */ |
| 114 | - public function findTasks (string $text, int $limit = 20) { |
|
| 114 | + public function findTasks(string $text, int $limit = 20) { |
|
| 115 | 115 | return $this->find(Task::class, Task::TYPE, $text, $limit); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param int $limit 1-100 |
| 123 | 123 | * @return User[] |
| 124 | 124 | */ |
| 125 | - public function findUsers (string $text, int $limit = 20) { |
|
| 125 | + public function findUsers(string $text, int $limit = 20) { |
|
| 126 | 126 | return $this->find(User::class, User::TYPE, $text, $limit); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param array $filter |
| 135 | 135 | * @return Project[] |
| 136 | 136 | */ |
| 137 | - public function getProjects (array $filter = ['archived' => false]) { |
|
| 137 | + public function getProjects(array $filter = ['archived' => false]) { |
|
| 138 | 138 | $filter['workspace'] = $this->getGid(); |
| 139 | 139 | return $this->loadAll(Project::class, 'projects', $filter); |
| 140 | 140 | } |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * @return Tag[] |
| 144 | 144 | */ |
| 145 | - public function getTags () { |
|
| 145 | + public function getTags() { |
|
| 146 | 146 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | 150 | * @return Team[] |
| 151 | 151 | */ |
| 152 | - public function getTeams () { |
|
| 152 | + public function getTeams() { |
|
| 153 | 153 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $email |
| 158 | 158 | * @return null|User |
| 159 | 159 | */ |
| 160 | - public function getUserByEmail (string $email) { |
|
| 160 | + public function getUserByEmail(string $email) { |
|
| 161 | 161 | return $this->api->getCache()->get($email, $this, function() use ($email) { |
| 162 | 162 | foreach ($this->getUsers() as $user) { |
| 163 | 163 | if ($user->getEmail() === $email) { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * @return User[] |
| 173 | 173 | */ |
| 174 | - public function getUsers () { |
|
| 174 | + public function getUsers() { |
|
| 175 | 175 | return $this->loadAll(User::class, "{$this}/users"); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return ProjectWebhook[]|TaskWebhook[] |
| 182 | 182 | */ |
| 183 | - public function getWebhooks () { |
|
| 183 | + public function getWebhooks() { |
|
| 184 | 184 | /** @var array $all */ |
| 185 | 185 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 186 | 186 | return array_map(function(array $each) { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | /** |
| 198 | 198 | * @return bool |
| 199 | 199 | */ |
| 200 | - public function isOrganization (): bool { |
|
| 200 | + public function isOrganization(): bool { |
|
| 201 | 201 | return $this->_is('is_organization'); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return CustomField |
| 208 | 208 | */ |
| 209 | - public function newCustomField () { |
|
| 209 | + public function newCustomField() { |
|
| 210 | 210 | /** @var CustomField $field */ |
| 211 | 211 | $field = $this->factory(CustomField::class); |
| 212 | 212 | return $field->setWorkspace($this); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return Portfolio |
| 219 | 219 | */ |
| 220 | - public function newPortfolio () { |
|
| 220 | + public function newPortfolio() { |
|
| 221 | 221 | /** @var Portfolio $portfolio */ |
| 222 | 222 | $portfolio = $this->factory(Portfolio::class); |
| 223 | 223 | return $portfolio->setWorkspace($this); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return Project |
| 230 | 230 | */ |
| 231 | - public function newProject () { |
|
| 231 | + public function newProject() { |
|
| 232 | 232 | /** @var Project $project */ |
| 233 | 233 | $project = $this->factory(Project::class); |
| 234 | 234 | return $project->setWorkspace($this); |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return Tag |
| 241 | 241 | */ |
| 242 | - public function newTag () { |
|
| 242 | + public function newTag() { |
|
| 243 | 243 | /** @var Tag $tag */ |
| 244 | 244 | $tag = $this->factory(Tag::class); |
| 245 | 245 | return $tag->setWorkspace($this); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return Task |
| 252 | 252 | */ |
| 253 | - public function newTask () { |
|
| 253 | + public function newTask() { |
|
| 254 | 254 | /** @var Task $task */ |
| 255 | 255 | $task = $this->factory(Task::class); |
| 256 | 256 | return $task->setWorkspace($this); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @param Workspace $workspace |
| 18 | 18 | * @return $this |
| 19 | 19 | */ |
| 20 | - public function setWorkspace (Workspace $workspace) { |
|
| 20 | + public function setWorkspace(Workspace $workspace) { |
|
| 21 | 21 | return $this->{'_set'}('workspace', $workspace); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | - abstract public function __toString (): string; |
|
| 23 | + abstract public function __toString(): string; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return $this |
| 40 | 40 | * @internal |
| 41 | 41 | */ |
| 42 | - protected function _addWithPost (string $path, array $data, string $field, array $diff) { |
|
| 42 | + protected function _addWithPost(string $path, array $data, string $field, array $diff) { |
|
| 43 | 43 | if ($this->hasGid()) { |
| 44 | 44 | return $this->_setWithPost($path, $data, $field); |
| 45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @internal |
| 53 | 53 | */ |
| 54 | - protected function _cache (): void { |
|
| 54 | + protected function _cache(): void { |
|
| 55 | 55 | $this->api->getCache()->add($this); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @internal |
| 62 | 62 | */ |
| 63 | - protected function _delete (): void { |
|
| 63 | + protected function _delete(): void { |
|
| 64 | 64 | $this->api->delete($this); |
| 65 | 65 | $this->api->getCache()->remove($this); |
| 66 | 66 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param string $field |
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | - protected function _get (string $field) { |
|
| 74 | + protected function _get(string $field) { |
|
| 75 | 75 | if (!array_key_exists($field, $this->data) and isset($this->data['gid'])) { |
| 76 | 76 | $this->reload($field); |
| 77 | 77 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return $this |
| 87 | 87 | * @internal |
| 88 | 88 | */ |
| 89 | - protected function _removeWithPost (string $path, array $data, string $field, $diff) { |
|
| 89 | + protected function _removeWithPost(string $path, array $data, string $field, $diff) { |
|
| 90 | 90 | if ($this->hasGid()) { |
| 91 | 91 | return $this->_setWithPost($path, $data, $field); |
| 92 | 92 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @return $this |
| 107 | 107 | * @internal |
| 108 | 108 | */ |
| 109 | - protected function _save (string $dir = null) { |
|
| 109 | + protected function _save(string $dir = null) { |
|
| 110 | 110 | if (isset($dir)) { |
| 111 | 111 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
| 112 | 112 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @return $this |
| 133 | 133 | * @internal |
| 134 | 134 | */ |
| 135 | - protected function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
| 135 | + protected function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
| 136 | 136 | if ($this->hasGid()) { |
| 137 | 137 | /** @var array $remote */ |
| 138 | 138 | $remote = $this->api->post($path, $data, ['fields' => static::$optFields[$field] ?? $field]); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return string[] |
| 152 | 152 | */ |
| 153 | - public function getCacheKeys () { |
|
| 153 | + public function getCacheKeys() { |
|
| 154 | 154 | return [$this->getGid(), (string)$this]; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param string $field |
| 162 | 162 | * @return $this |
| 163 | 163 | */ |
| 164 | - public function reload (string $field = null) { |
|
| 164 | + public function reload(string $field = null) { |
|
| 165 | 165 | if (!$this->hasGid()) { |
| 166 | 166 | throw new LogicException(static::class . " has no GID, it can't be reloaded."); |
| 167 | 167 | } |
@@ -89,11 +89,9 @@ discard block |
||
| 89 | 89 | protected function _removeWithPost (string $path, array $data, string $field, $diff) { |
| 90 | 90 | if ($this->hasGid()) { |
| 91 | 91 | return $this->_setWithPost($path, $data, $field); |
| 92 | - } |
|
| 93 | - elseif (is_array($diff)) { |
|
| 92 | + } elseif (is_array($diff)) { |
|
| 94 | 93 | $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
| 95 | - } |
|
| 96 | - elseif ($diff instanceof Closure) { |
|
| 94 | + } elseif ($diff instanceof Closure) { |
|
| 97 | 95 | $this->_set($field, array_filter($this->data[$field] ?? [], $diff)); |
| 98 | 96 | } |
| 99 | 97 | return $this; |
@@ -109,11 +107,9 @@ discard block |
||
| 109 | 107 | protected function _save (string $dir = null) { |
| 110 | 108 | if (isset($dir)) { |
| 111 | 109 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
| 112 | - } |
|
| 113 | - elseif ($this->isDiff()) { |
|
| 110 | + } elseif ($this->isDiff()) { |
|
| 114 | 111 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
| 115 | - } |
|
| 116 | - else { |
|
| 112 | + } else { |
|
| 117 | 113 | return $this; |
| 118 | 114 | } |
| 119 | 115 | /** @var array $remote */ |
@@ -169,11 +165,9 @@ discard block |
||
| 169 | 165 | $optField = static::$optFields[$field] ?? $field; |
| 170 | 166 | $value = $this->api->get($this, [], ['fields' => $optField])[$field] ?? null; |
| 171 | 167 | $this->_setMapped($field, $value); |
| 172 | - } |
|
| 173 | - elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
| 168 | + } elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
| 174 | 169 | $this->_setData($remote); |
| 175 | - } |
|
| 176 | - else { // deleted upstream. |
|
| 170 | + } else { // deleted upstream. |
|
| 177 | 171 | $this->api->getCache()->remove($this); |
| 178 | 172 | throw new RuntimeException("{$this} was deleted upstream."); |
| 179 | 173 | } |
@@ -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 $field, $value) { |
|
| 39 | + protected function _set(string $field, $value) { |
|
| 40 | 40 | $this->task->diff['external'] = true; |
| 41 | 41 | return parent::_set($field, $value); |
| 42 | 42 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return null|bool|number|string|array |
| 48 | 48 | */ |
| 49 | - public function getDataJsonDecoded () { |
|
| 49 | + public function getDataJsonDecoded() { |
|
| 50 | 50 | if (strlen($data = $this->getData())) { |
| 51 | - return json_decode($data, true, 512, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 51 | + return json_decode($data, true, 512, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 52 | 52 | } |
| 53 | 53 | return null; |
| 54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param mixed $data |
| 61 | 61 | * @return $this |
| 62 | 62 | */ |
| 63 | - public function setDataJsonEncoded ($data) { |
|
| 63 | + public function setDataJsonEncoded($data) { |
|
| 64 | 64 | if (isset($data)) { |
| 65 | 65 | return $this->setData(json_encode($data, JSON_THROW_ON_ERROR)); |
| 66 | 66 | } |