@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | const TYPE = 'workspace'; |
29 | 29 | |
30 | - final public function __toString (): string { |
|
30 | + final public function __toString(): string { |
|
31 | 31 | return "workspaces/{$this->getGid()}"; |
32 | 32 | } |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return OrganizationExport |
38 | 38 | */ |
39 | - public function export () { |
|
39 | + public function export() { |
|
40 | 40 | /** @var OrganizationExport $export */ |
41 | 41 | $export = $this->api->factory($this, OrganizationExport::class); |
42 | 42 | return $export->create($this); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param int $limit 1-100 |
57 | 57 | * @return array|AbstractEntity[] |
58 | 58 | */ |
59 | - protected function find (string $class, string $text, int $limit = 20) { |
|
59 | + protected function find(string $class, string $text, int $limit = 20) { |
|
60 | 60 | return $this->api->loadAll($this, $class, "{$this}/typeahead", [ |
61 | 61 | 'resource_type' => $class::TYPE, |
62 | 62 | 'query' => $text, |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param int $limit 1-100 |
72 | 72 | * @return CustomField[] |
73 | 73 | */ |
74 | - public function findCustomFields (string $text, int $limit = 20) { |
|
74 | + public function findCustomFields(string $text, int $limit = 20) { |
|
75 | 75 | return $this->find(CustomField::class, $text, $limit); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int $limit 1-100 |
83 | 83 | * @return Portfolio[] |
84 | 84 | */ |
85 | - public function findPortfolios (string $text, int $limit = 20) { |
|
85 | + public function findPortfolios(string $text, int $limit = 20) { |
|
86 | 86 | return $this->find(Portfolio::class, $text, $limit); |
87 | 87 | } |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param int $limit 1-100 |
94 | 94 | * @return Project[] |
95 | 95 | */ |
96 | - public function findProjects (string $text, int $limit = 20) { |
|
96 | + public function findProjects(string $text, int $limit = 20) { |
|
97 | 97 | return $this->find(Project::class, $text, $limit); |
98 | 98 | } |
99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param int $limit 1-100 |
105 | 105 | * @return Tag[] |
106 | 106 | */ |
107 | - public function findTags (string $text, int $limit = 20) { |
|
107 | + public function findTags(string $text, int $limit = 20) { |
|
108 | 108 | return $this->find(Tag::class, $text, $limit); |
109 | 109 | } |
110 | 110 | |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @param int $limit 1-100 |
116 | 116 | * @return Task[] |
117 | 117 | */ |
118 | - public function findTasks (string $text, int $limit = 20) { |
|
118 | + public function findTasks(string $text, int $limit = 20) { |
|
119 | 119 | return $this->find(Task::class, $text, $limit); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @return CustomField[] |
124 | 124 | */ |
125 | - public function getCustomFields () { |
|
125 | + public function getCustomFields() { |
|
126 | 126 | return $this->api->loadAll($this, CustomField::class, "{$this}/custom_fields"); |
127 | 127 | } |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return Portfolio[] |
135 | 135 | */ |
136 | - public function getPortfolios () { |
|
136 | + public function getPortfolios() { |
|
137 | 137 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
138 | 138 | 'workspace' => $this->getGid(), |
139 | 139 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param array $filter |
147 | 147 | * @return Project[] |
148 | 148 | */ |
149 | - public function getProjects (array $filter = Project::FILTER_ACTIVE) { |
|
149 | + public function getProjects(array $filter = Project::FILTER_ACTIVE) { |
|
150 | 150 | $filter['workspace'] = $this->getGid(); |
151 | 151 | return $this->api->loadAll($this, Project::class, 'projects', $filter); |
152 | 152 | } |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @return Tag[] |
156 | 156 | */ |
157 | - public function getTags () { |
|
157 | + public function getTags() { |
|
158 | 158 | return $this->api->loadAll($this, Tag::class, 'tags', ['workspace' => $this->getGid()]); |
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * @return Team[] |
163 | 163 | */ |
164 | - public function getTeams () { |
|
164 | + public function getTeams() { |
|
165 | 165 | return $this->api->loadAll($this, Team::class, "organizations/{$this->getGid()}/teams"); |
166 | 166 | } |
167 | 167 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $email |
170 | 170 | * @return null|User |
171 | 171 | */ |
172 | - public function getUserByEmail (string $email) { |
|
172 | + public function getUserByEmail(string $email) { |
|
173 | 173 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
174 | 174 | foreach ($this->getUsers() as $user) { |
175 | 175 | if ($user->getEmail() === $email) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * @return User[] |
185 | 185 | */ |
186 | - public function getUsers () { |
|
186 | + public function getUsers() { |
|
187 | 187 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
188 | 188 | } |
189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return ProjectWebhook[]|TaskWebhook[] |
194 | 194 | */ |
195 | - public function getWebhooks () { |
|
195 | + public function getWebhooks() { |
|
196 | 196 | /** @var array $all */ |
197 | 197 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
198 | 198 | return array_map(function(array $each) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | /** |
210 | 210 | * @return bool |
211 | 211 | */ |
212 | - public function isOrganization (): bool { |
|
212 | + public function isOrganization(): bool { |
|
213 | 213 | return $this->_is('is_organization'); |
214 | 214 | } |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return CustomField |
220 | 220 | */ |
221 | - public function newCustomField () { |
|
221 | + public function newCustomField() { |
|
222 | 222 | /** @var CustomField $field */ |
223 | 223 | $field = $this->api->factory($this, CustomField::class); |
224 | 224 | return $field->setWorkspace($this); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return Portfolio |
231 | 231 | */ |
232 | - public function newPortfolio () { |
|
232 | + public function newPortfolio() { |
|
233 | 233 | /** @var Portfolio $portfolio */ |
234 | 234 | $portfolio = $this->api->factory($this, Portfolio::class); |
235 | 235 | return $portfolio->setWorkspace($this); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return Project |
242 | 242 | */ |
243 | - public function newProject () { |
|
243 | + public function newProject() { |
|
244 | 244 | /** @var Project $project */ |
245 | 245 | $project = $this->api->factory($this, Project::class); |
246 | 246 | return $project->setWorkspace($this); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return Tag |
253 | 253 | */ |
254 | - public function newTag () { |
|
254 | + public function newTag() { |
|
255 | 255 | /** @var Tag $tag */ |
256 | 256 | $tag = $this->api->factory($this, Tag::class); |
257 | 257 | return $tag->setWorkspace($this); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return Task |
264 | 264 | */ |
265 | - public function newTask () { |
|
265 | + public function newTask() { |
|
266 | 266 | /** @var Task $task */ |
267 | 267 | $task = $this->api->factory($this, Task::class); |
268 | 268 | return $task->setWorkspace($this); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param callable $filter `fn( CustomField $field ): bool` |
273 | 273 | * @return CustomField[] |
274 | 274 | */ |
275 | - public function selectCustomFields (callable $filter) { |
|
275 | + public function selectCustomFields(callable $filter) { |
|
276 | 276 | return $this->_select($this->getCustomFields(), $filter); |
277 | 277 | } |
278 | 278 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
281 | 281 | * @return Portfolio[] |
282 | 282 | */ |
283 | - public function selectPortfolios (callable $filter) { |
|
283 | + public function selectPortfolios(callable $filter) { |
|
284 | 284 | return $this->_select($this->getPortfolios(), $filter); |
285 | 285 | } |
286 | 286 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param callable $filter `fn( Project $project ): bool` |
289 | 289 | * @return Project[] |
290 | 290 | */ |
291 | - public function selectProjects (callable $filter) { |
|
291 | + public function selectProjects(callable $filter) { |
|
292 | 292 | return $this->_select($this->getProjects([]), $filter); |
293 | 293 | } |
294 | 294 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param callable $filter `fn( Tag $tag ): bool` |
297 | 297 | * @return Tag[] |
298 | 298 | */ |
299 | - public function selectTags (callable $filter) { |
|
299 | + public function selectTags(callable $filter) { |
|
300 | 300 | return $this->_select($this->getTags(), $filter); |
301 | 301 | } |
302 | 302 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param callable $filter `fn( Team $team ): bool` |
305 | 305 | * @return Team[] |
306 | 306 | */ |
307 | - public function selectTeams (callable $filter) { |
|
307 | + public function selectTeams(callable $filter) { |
|
308 | 308 | return $this->_select($this->getTeams(), $filter); |
309 | 309 | } |
310 | 310 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param callable $filter |
313 | 313 | * @return User[] |
314 | 314 | */ |
315 | - public function selectUsers (callable $filter) { |
|
315 | + public function selectUsers(callable $filter) { |
|
316 | 316 | return $this->_select($this->getUsers(), $filter); |
317 | 317 | } |
318 | 318 | } |
319 | 319 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'workspaces' => [Workspace::class] |
29 | 29 | ]; |
30 | 30 | |
31 | - final public function __toString (): string { |
|
31 | + final public function __toString(): string { |
|
32 | 32 | return "users/{$this->getGid()}"; |
33 | 33 | } |
34 | 34 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param Workspace $workspace |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - public function addToWorkspace (Workspace $workspace) { |
|
39 | + public function addToWorkspace(Workspace $workspace) { |
|
40 | 40 | return $this->_addWithPost("{$workspace}/addUser", [ |
41 | 41 | 'user' => $this->getGid() |
42 | 42 | ], 'workspaces', [$workspace]); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @return string[] |
47 | 47 | */ |
48 | - public function getCacheKeys () { |
|
48 | + public function getCacheKeys() { |
|
49 | 49 | $keys = parent::getCacheKeys(); |
50 | 50 | |
51 | 51 | // only include email as a key if it's loaded |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return Workspace |
64 | 64 | */ |
65 | - public function getDefaultWorkspace () { |
|
65 | + public function getDefaultWorkspace() { |
|
66 | 66 | return $this->getWorkspaces()[0]; |
67 | 67 | } |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param null|Workspace $workspace Falls back to the default workspace. |
71 | 71 | * @return Portfolio[] |
72 | 72 | */ |
73 | - public function getFavoritePortfolios (Workspace $workspace = null) { |
|
73 | + public function getFavoritePortfolios(Workspace $workspace = null) { |
|
74 | 74 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
75 | 75 | } |
76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param null|Workspace $workspace Falls back to the default workspace. |
79 | 79 | * @return Project[] |
80 | 80 | */ |
81 | - public function getFavoriteProjects (Workspace $workspace = null) { |
|
81 | + public function getFavoriteProjects(Workspace $workspace = null) { |
|
82 | 82 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
83 | 83 | } |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param null|Workspace $workspace Falls back to the default workspace. |
87 | 87 | * @return Tag[] |
88 | 88 | */ |
89 | - public function getFavoriteTags (Workspace $workspace = null) { |
|
89 | + public function getFavoriteTags(Workspace $workspace = null) { |
|
90 | 90 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param null|Workspace $workspace Falls back to the default workspace. |
95 | 95 | * @return Team[] |
96 | 96 | */ |
97 | - public function getFavoriteTeams (Workspace $workspace = null) { |
|
97 | + public function getFavoriteTeams(Workspace $workspace = null) { |
|
98 | 98 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param null|Workspace $workspace Falls back to the default workspace. |
103 | 103 | * @return User[] |
104 | 104 | */ |
105 | - public function getFavoriteUsers (Workspace $workspace = null) { |
|
105 | + public function getFavoriteUsers(Workspace $workspace = null) { |
|
106 | 106 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
107 | 107 | } |
108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param null|Workspace $workspace Falls back to the default workspace. |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) { |
|
115 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) { |
|
116 | 116 | return $this->api->loadAll($this, $class, "{$this}/favorites", [ |
117 | 117 | 'resource_type' => $resourceType, |
118 | 118 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid() |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param null|Workspace $workspace |
124 | 124 | * @return Portfolio[] |
125 | 125 | */ |
126 | - public function getPortfolios (Workspace $workspace = null) { |
|
126 | + public function getPortfolios(Workspace $workspace = null) { |
|
127 | 127 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
128 | 128 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid(), |
129 | 129 | 'owner' => $this->getGid() |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param null|Workspace $workspace Falls back to the default workspace. |
135 | 135 | * @return TaskList |
136 | 136 | */ |
137 | - public function getTaskList (Workspace $workspace = null) { |
|
137 | + public function getTaskList(Workspace $workspace = null) { |
|
138 | 138 | return $this->api->load($this, TaskList::class, "{$this}/user_task_list", [ |
139 | 139 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid() |
140 | 140 | ]); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param string[] $filter `workspace` falls back to the default. |
147 | 147 | * @return Task[] |
148 | 148 | */ |
149 | - public function getTasks (array $filter = []) { |
|
149 | + public function getTasks(array $filter = []) { |
|
150 | 150 | $filter['assignee'] = $this->getGid(); |
151 | 151 | $filter += ['workspace' => $this->api->getDefaultWorkspace()->getGid()]; |
152 | 152 | return $this->api->loadAll($this, Task::class, 'tasks', $filter); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | * @param null|Workspace $organization Falls back to the default workspace. |
161 | 161 | * @return Team[] |
162 | 162 | */ |
163 | - public function getTeams (Workspace $organization = null) { |
|
163 | + public function getTeams(Workspace $organization = null) { |
|
164 | 164 | return $this->api->loadAll($this, Team::class, "{$this}/teams", [ |
165 | 165 | 'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid() |
166 | 166 | ]); |
167 | 167 | } |
168 | 168 | |
169 | - public function getUrl (): string { |
|
169 | + public function getUrl(): string { |
|
170 | 170 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param Workspace $workspace |
175 | 175 | * @return $this |
176 | 176 | */ |
177 | - public function removeFromWorkspace (Workspace $workspace) { |
|
177 | + public function removeFromWorkspace(Workspace $workspace) { |
|
178 | 178 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
179 | 179 | 'user' => $this->getGid() |
180 | 180 | ], 'workspaces', [$workspace]); |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | class Event extends Data { |
44 | 44 | |
45 | - const ACTION_CHANGED = 'changed'; // no parent |
|
46 | - const ACTION_ADDED = 'added'; // relational, no change |
|
47 | - const ACTION_REMOVED = 'removed'; // relational, no change |
|
48 | - const ACTION_DELETED = 'deleted'; // no parent or change |
|
49 | - const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
45 | + const ACTION_CHANGED = 'changed'; // no parent |
|
46 | + const ACTION_ADDED = 'added'; // relational, no change |
|
47 | + const ACTION_REMOVED = 'removed'; // relational, no change |
|
48 | + const ACTION_DELETED = 'deleted'; // no parent or change |
|
49 | + const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
50 | 50 | |
51 | 51 | const GRAPH = [ |
52 | 52 | User::TYPE => User::class, |
@@ -71,35 +71,35 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - final public function wasAddition (): bool { |
|
74 | + final public function wasAddition(): bool { |
|
75 | 75 | return $this->getAction() === self::ACTION_ADDED; |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - final public function wasChange (): bool { |
|
81 | + final public function wasChange(): bool { |
|
82 | 82 | return $this->getAction() === self::ACTION_CHANGED; |
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - final public function wasDeletion (): bool { |
|
88 | + final public function wasDeletion(): bool { |
|
89 | 89 | return $this->getAction() === self::ACTION_DELETED; |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - final public function wasRemoval (): bool { |
|
95 | + final public function wasRemoval(): bool { |
|
96 | 96 | return $this->getAction() === self::ACTION_REMOVED; |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return bool |
101 | 101 | */ |
102 | - final public function wasUndeletion (): bool { |
|
102 | + final public function wasUndeletion(): bool { |
|
103 | 103 | return $this->getAction() === self::ACTION_UNDELETED; |
104 | 104 | } |
105 | 105 |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | */ |
78 | 78 | private $defaultSection; |
79 | 79 | |
80 | - final public function __toString (): string { |
|
80 | + final public function __toString(): string { |
|
81 | 81 | return "projects/{$this->getGid()}"; |
82 | 82 | } |
83 | 83 | |
84 | - final protected function _getDir (): string { |
|
84 | + final protected function _getDir(): string { |
|
85 | 85 | return 'projects'; |
86 | 86 | } |
87 | 87 | |
88 | - protected function _setData (array $data): void { |
|
88 | + protected function _setData(array $data): void { |
|
89 | 89 | // this is always empty. fields are in the settings, values are in tasks. |
90 | 90 | unset($data['custom_fields']); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param User $user |
101 | 101 | * @return $this |
102 | 102 | */ |
103 | - public function addMember (User $user) { |
|
103 | + public function addMember(User $user) { |
|
104 | 104 | return $this->addMembers([$user]); |
105 | 105 | } |
106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param User[] $users |
110 | 110 | * @return $this |
111 | 111 | */ |
112 | - public function addMembers (array $users) { |
|
112 | + public function addMembers(array $users) { |
|
113 | 113 | return $this->_addWithPost("{$this}/addMembers", [ |
114 | 114 | 'members' => array_column($users, 'gid') |
115 | 115 | ], 'members', $users); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param string $target |
121 | 121 | * @return ProjectWebhook |
122 | 122 | */ |
123 | - public function addWebhook (string $target) { |
|
123 | + public function addWebhook(string $target) { |
|
124 | 124 | /** @var ProjectWebhook $webhook */ |
125 | 125 | $webhook = $this->api->factory($this, ProjectWebhook::class); |
126 | 126 | return $webhook->create($this, $target); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param array $schedule |
146 | 146 | * @return Job |
147 | 147 | */ |
148 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
148 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
149 | 149 | $data = ['name' => $name]; |
150 | 150 | if ($team) { |
151 | 151 | $data['team'] = $team->getGid(); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @depends after-create |
165 | 165 | * @return Section |
166 | 166 | */ |
167 | - public function getDefaultSection () { |
|
167 | + public function getDefaultSection() { |
|
168 | 168 | return $this->defaultSection ?? |
169 | 169 | $this->defaultSection = $this->api->loadAll($this, Section::class, "{$this}/sections", ['limit' => 1])[0]; |
170 | 170 | } |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | * @param null|string $token |
179 | 179 | * @return Event[] |
180 | 180 | */ |
181 | - public function getEvents (&$token) { |
|
181 | + public function getEvents(&$token) { |
|
182 | 182 | return $this->api->sync($this->getGid(), $token); |
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @return Traversable|Section[] |
187 | 187 | */ |
188 | - public function getIterator () { |
|
188 | + public function getIterator() { |
|
189 | 189 | return $this->api->loadEach($this, Section::class, "{$this}/sections"); |
190 | 190 | } |
191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @depends after-create |
194 | 194 | * @return Section[] |
195 | 195 | */ |
196 | - public function getSections () { |
|
196 | + public function getSections() { |
|
197 | 197 | return iterator_to_array($this); |
198 | 198 | } |
199 | 199 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @depends after-create |
202 | 202 | * @return Status[] |
203 | 203 | */ |
204 | - public function getStatuses () { |
|
204 | + public function getStatuses() { |
|
205 | 205 | return $this->api->loadAll($this, Status::class, "{$this}/project_statuses"); |
206 | 206 | } |
207 | 207 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param array $filter |
213 | 213 | * @return Task[] |
214 | 214 | */ |
215 | - public function getTasks (array $filter = []) { |
|
215 | + public function getTasks(array $filter = []) { |
|
216 | 216 | $filter['project'] = $this->getGid(); |
217 | 217 | return $this->api->loadAll($this, Task::class, "tasks", $filter); |
218 | 218 | } |
@@ -221,25 +221,25 @@ discard block |
||
221 | 221 | * @depends after-create |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - public function getUrl (): string { |
|
224 | + public function getUrl(): string { |
|
225 | 225 | return "https://app.asana.com/0/{$this->getGid()}"; |
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @return ProjectWebhook[] |
230 | 230 | */ |
231 | - public function getWebhooks () { |
|
231 | + public function getWebhooks() { |
|
232 | 232 | return $this->api->loadAll($this, ProjectWebhook::class, 'webhooks', [ |
233 | 233 | 'workspace' => $this->getWorkspace()->getGid(), |
234 | 234 | 'resource' => $this->getGid() |
235 | 235 | ]); |
236 | 236 | } |
237 | 237 | |
238 | - public function isBoard (): bool { |
|
238 | + public function isBoard(): bool { |
|
239 | 239 | return $this->getLayout() === self::LAYOUT_BOARD; |
240 | 240 | } |
241 | 241 | |
242 | - public function isList (): bool { |
|
242 | + public function isList(): bool { |
|
243 | 243 | return $this->getLayout() === self::LAYOUT_LIST; |
244 | 244 | } |
245 | 245 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @depends after-create |
248 | 248 | * @return Section |
249 | 249 | */ |
250 | - public function newSection () { |
|
250 | + public function newSection() { |
|
251 | 251 | return $this->api->factory($this, Section::class, ['project' => $this]); |
252 | 252 | } |
253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @depends after-create |
256 | 256 | * @return Status |
257 | 257 | */ |
258 | - public function newStatus () { |
|
258 | + public function newStatus() { |
|
259 | 259 | return $this->api->factory($this, Status::class); |
260 | 260 | } |
261 | 261 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @depends after-create |
266 | 266 | * @return Task |
267 | 267 | */ |
268 | - public function newTask () { |
|
268 | + public function newTask() { |
|
269 | 269 | return $this->getDefaultSection()->newTask(); |
270 | 270 | } |
271 | 271 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param User $user |
275 | 275 | * @return $this |
276 | 276 | */ |
277 | - public function removeMember (User $user) { |
|
277 | + public function removeMember(User $user) { |
|
278 | 278 | return $this->removeMembers([$user]); |
279 | 279 | } |
280 | 280 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param User[] $users |
284 | 284 | * @return $this |
285 | 285 | */ |
286 | - public function removeMembers (array $users) { |
|
286 | + public function removeMembers(array $users) { |
|
287 | 287 | return $this->_removeWithPost("{$this}/removeMembers", [ |
288 | 288 | 'members' => array_column($users, 'gid') |
289 | 289 | ], 'members', $users); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param callable $filter `fn( Section $section ): bool` |
294 | 294 | * @return Section[] |
295 | 295 | */ |
296 | - public function selectSections (callable $filter) { |
|
296 | + public function selectSections(callable $filter) { |
|
297 | 297 | return $this->_select($this->getSections(), $filter); |
298 | 298 | } |
299 | 299 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param callable $filter `fn( Status $status ): bool` |
302 | 302 | * @return Status[] |
303 | 303 | */ |
304 | - public function selectStatuses (callable $filter) { |
|
304 | + public function selectStatuses(callable $filter) { |
|
305 | 305 | return $this->_select($this->getStatuses(), $filter); |
306 | 306 | } |
307 | 307 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param array $apiFilter Pre-filter given to the API to reduce network load. |
311 | 311 | * @return Task[] |
312 | 312 | */ |
313 | - public function selectTasks (callable $filter, array $apiFilter = []) { |
|
313 | + public function selectTasks(callable $filter, array $apiFilter = []) { |
|
314 | 314 | return $this->_select($this->getTasks($apiFilter), $filter); |
315 | 315 | } |
316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param null|Team $team |
320 | 320 | * @return $this |
321 | 321 | */ |
322 | - public function setTeam (?Team $team) { |
|
322 | + public function setTeam(?Team $team) { |
|
323 | 323 | if ($team and !$this->hasWorkspace()) { |
324 | 324 | $this->setWorkspace($team->getOrganization()); |
325 | 325 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param AbstractEntity $entity |
35 | 35 | * @return bool Success? |
36 | 36 | */ |
37 | - public function add (AbstractEntity $entity): bool { |
|
37 | + public function add(AbstractEntity $entity): bool { |
|
38 | 38 | if (!$entity->isDiff() and $gid = $entity->getGid()) { |
39 | 39 | $this->entities[$gid] = $entity; |
40 | 40 | $this->addKeys($gid, $entity->getCacheKeys()); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $gid |
50 | 50 | * @param string[] $keys |
51 | 51 | */ |
52 | - protected function addKeys (string $gid, array $keys): void { |
|
52 | + protected function addKeys(string $gid, array $keys): void { |
|
53 | 53 | $this->gids += array_fill_keys($keys, $gid); |
54 | 54 | } |
55 | 55 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param Closure $factory `fn( Api|Data $caller ): null|AbstractEntity` |
65 | 65 | * @return null|mixed|AbstractEntity |
66 | 66 | */ |
67 | - public function get (string $key, $caller, Closure $factory) { |
|
67 | + public function get(string $key, $caller, Closure $factory) { |
|
68 | 68 | // POOL HIT |
69 | 69 | if ($gid = $this->gids[$key] ?? null) { |
70 | 70 | return $this->entities[$gid]; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param string[] $keys |
95 | 95 | */ |
96 | - public function remove (array $keys): void { |
|
96 | + public function remove(array $keys): void { |
|
97 | 97 | foreach ($keys as $key) { |
98 | 98 | unset($this->entities[$key]); |
99 | 99 | unset($this->gids[$key]); |
@@ -36,26 +36,26 @@ discard block |
||
36 | 36 | * @param string $dir |
37 | 37 | * @param bool $gz |
38 | 38 | */ |
39 | - public function __construct (string $dir, $gz = false) { |
|
39 | + public function __construct(string $dir, $gz = false) { |
|
40 | 40 | $this->dir = $dir; |
41 | 41 | $this->gz = $gz; |
42 | 42 | } |
43 | 43 | |
44 | - private function _path ($key): string { |
|
44 | + private function _path($key): string { |
|
45 | 45 | $path = "{$this->dir}/{$key}~"; |
46 | 46 | clearstatcache(true, $path); |
47 | 47 | return $path; |
48 | 48 | } |
49 | 49 | |
50 | - private function _ref ($key): string { |
|
50 | + private function _ref($key): string { |
|
51 | 51 | return "{$this->dir}/{$key}.ref"; |
52 | 52 | } |
53 | 53 | |
54 | - public function clear () { |
|
54 | + public function clear() { |
|
55 | 55 | // unused. just delete the dir. |
56 | 56 | } |
57 | 57 | |
58 | - public function delete ($key) { |
|
58 | + public function delete($key) { |
|
59 | 59 | $path = $this->_path($key); |
60 | 60 | if (is_link($ref = $this->_ref($key))) { |
61 | 61 | $this->log('CACHE DELINK', $key); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - public function deleteMultiple ($keys) { |
|
71 | + public function deleteMultiple($keys) { |
|
72 | 72 | // unused |
73 | 73 | } |
74 | 74 | |
75 | - public function get ($key, $default = null) { |
|
75 | + public function get($key, $default = null) { |
|
76 | 76 | $path = $this->_path($key); |
77 | 77 | if (is_file($path)) { |
78 | 78 | if (filemtime($path) > time()) { |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @return LoggerInterface |
97 | 97 | */ |
98 | - public function getLogger () { |
|
98 | + public function getLogger() { |
|
99 | 99 | return $this->logger; |
100 | 100 | } |
101 | 101 | |
102 | - public function getMultiple ($keys, $default = null) { |
|
102 | + public function getMultiple($keys, $default = null) { |
|
103 | 103 | // unused |
104 | 104 | } |
105 | 105 | |
106 | - public function has ($key) { |
|
106 | + public function has($key) { |
|
107 | 107 | // unused |
108 | 108 | } |
109 | 109 | |
110 | - private function log (string $msg, string $key): void { |
|
110 | + private function log(string $msg, string $key): void { |
|
111 | 111 | if ($this->logger) { |
112 | 112 | $this->logger->log($msg, $key); |
113 | 113 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param DateInterval $ttl |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function set ($key, $value, $ttl = null): void { |
|
122 | + public function set($key, $value, $ttl = null): void { |
|
123 | 123 | assert($ttl instanceof DateInterval); |
124 | 124 | $path = $this->_path($key); |
125 | 125 | $data = serialize($value); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * @param null|LoggerInterface $logger |
147 | 147 | * @return $this |
148 | 148 | */ |
149 | - public function setLogger (?LoggerInterface $logger) { |
|
149 | + public function setLogger(?LoggerInterface $logger) { |
|
150 | 150 | $this->logger = $logger; |
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
154 | - public function setMultiple ($values, $ttl = null) { |
|
154 | + public function setMultiple($values, $ttl = null) { |
|
155 | 155 | // unused |
156 | 156 | } |
157 | 157 | } |
158 | 158 | \ No newline at end of file |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | $this->log('CACHE DELINK', $key); |
62 | 62 | unlink($ref); |
63 | 63 | unlink($path); |
64 | - } |
|
65 | - elseif (is_file($path)) { |
|
64 | + } elseif (is_file($path)) { |
|
66 | 65 | $this->log('CACHE DELETE', $key); |
67 | 66 | unlink($path); |
68 | 67 | } |
@@ -85,8 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | $this->log('CACHE EXPIRE', $key); |
87 | 86 | unlink($path); |
88 | - } |
|
89 | - else { |
|
87 | + } else { |
|
90 | 88 | $this->log('CACHE MISS', $key); |
91 | 89 | } |
92 | 90 | return $default; |
@@ -132,8 +130,7 @@ discard block |
||
132 | 130 | if (is_object($value)) { |
133 | 131 | $this->log('CACHE SET', $key); |
134 | 132 | file_put_contents($path, $data); |
135 | - } |
|
136 | - elseif (!file_exists($path)) { |
|
133 | + } elseif (!file_exists($path)) { |
|
137 | 134 | $this->log('CACHE LINK', "{$key} => asana/{$value}"); |
138 | 135 | file_put_contents($path, $data); |
139 | 136 | symlink($this->_path("asana/{$value}"), $this->_ref($key)); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @param PSR16 $psr |
36 | 36 | */ |
37 | - public function __construct (PSR16 $psr) { |
|
37 | + public function __construct(PSR16 $psr) { |
|
38 | 38 | $this->psr = $psr; |
39 | 39 | $this->ttl = new DateInterval('PT1H'); |
40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $key |
44 | 44 | * @throws CacheException |
45 | 45 | */ |
46 | - protected function _delete (string $key): void { |
|
46 | + protected function _delete(string $key): void { |
|
47 | 47 | $this->psr->delete('asana/' . $key); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return null|string|AbstractEntity |
53 | 53 | * @throws CacheException |
54 | 54 | */ |
55 | - protected function _get (string $key) { |
|
55 | + protected function _get(string $key) { |
|
56 | 56 | return $this->psr->get('asana/' . $key); |
57 | 57 | } |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param mixed $value |
62 | 62 | * @throws CacheException |
63 | 63 | */ |
64 | - protected function _set (string $key, $value): void { |
|
64 | + protected function _set(string $key, $value): void { |
|
65 | 65 | $this->psr->set('asana/' . $key, $value, $this->ttl); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | * @throws CacheException |
72 | 72 | */ |
73 | - public function add (AbstractEntity $entity): bool { |
|
73 | + public function add(AbstractEntity $entity): bool { |
|
74 | 74 | if (!$entity->isDiff() and $gid = $entity->getGid()) { |
75 | 75 | $this->_set($gid, $entity); |
76 | 76 | return parent::add($entity); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string[] $keys |
84 | 84 | * @throws CacheException |
85 | 85 | */ |
86 | - protected function addKeys (string $gid, array $keys): void { |
|
86 | + protected function addKeys(string $gid, array $keys): void { |
|
87 | 87 | parent::addKeys($gid, $keys); |
88 | 88 | // stash gid refs |
89 | 89 | foreach ($keys as $key) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return null|AbstractEntity |
101 | 101 | * @throws CacheException |
102 | 102 | */ |
103 | - public function get (string $key, $caller, Closure $factory) { |
|
103 | + public function get(string $key, $caller, Closure $factory) { |
|
104 | 104 | // POOL MISS && CACHE HIT |
105 | 105 | if (!isset($this->gids[$key]) and $entity = $this->_get($key)) { |
106 | 106 | if ($entity instanceof AbstractEntity) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * @return DateInterval |
127 | 127 | */ |
128 | - public function getTtl () { |
|
128 | + public function getTtl() { |
|
129 | 129 | return $this->ttl; |
130 | 130 | } |
131 | 131 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param array $keys |
134 | 134 | * @throws CacheException |
135 | 135 | */ |
136 | - public function remove (array $keys): void { |
|
136 | + public function remove(array $keys): void { |
|
137 | 137 | parent::remove($keys); |
138 | 138 | foreach ($keys as $key) { |
139 | 139 | $this->_delete($key); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param DateInterval $ttl |
145 | 145 | * @return $this |
146 | 146 | */ |
147 | - public function setTtl (DateInterval $ttl) { |
|
147 | + public function setTtl(DateInterval $ttl) { |
|
148 | 148 | $this->ttl = $ttl; |
149 | 149 | return $this; |
150 | 150 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - abstract public function __toString (): string; |
|
24 | + abstract public function __toString(): string; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return $this |
43 | 43 | * @internal |
44 | 44 | */ |
45 | - public function __set ($unused, self $entity) { |
|
45 | + public function __set($unused, self $entity) { |
|
46 | 46 | if ($entity !== $this) { |
47 | 47 | $this->data = array_merge($this->data, array_diff_key($entity->data, $this->diff)); |
48 | 48 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return $this |
58 | 58 | * @internal |
59 | 59 | */ |
60 | - protected function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
60 | + protected function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
61 | 61 | if ($this->hasGid()) { |
62 | 62 | return $this->_setWithPost($addPath, $data, $field); |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @internal |
71 | 71 | */ |
72 | - protected function _cache (): void { |
|
72 | + protected function _cache(): void { |
|
73 | 73 | $this->api->getCache()->add($this); |
74 | 74 | } |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @internal |
80 | 80 | */ |
81 | - protected function _delete (): void { |
|
81 | + protected function _delete(): void { |
|
82 | 82 | $this->api->delete($this); |
83 | 83 | $this->api->getCache()->remove($this->getCacheKeys()); |
84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param string $field |
90 | 90 | * @return mixed |
91 | 91 | */ |
92 | - protected function _get (string $field) { |
|
92 | + protected function _get(string $field) { |
|
93 | 93 | if (!array_key_exists($field, $this->data) and $this->hasGid()) { |
94 | 94 | $this->reload($field); |
95 | 95 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return $this |
105 | 105 | * @internal |
106 | 106 | */ |
107 | - protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
107 | + protected function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
108 | 108 | if ($this->hasGid()) { |
109 | 109 | return $this->_setWithPost($rmPath, $data, $field); |
110 | 110 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return $this |
122 | 122 | * @internal |
123 | 123 | */ |
124 | - protected function _save (string $dir = null) { |
|
124 | + protected function _save(string $dir = null) { |
|
125 | 125 | if (isset($dir)) { |
126 | 126 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
127 | 127 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
140 | - protected function _setData (array $data): void { |
|
140 | + protected function _setData(array $data): void { |
|
141 | 141 | // make sure gid is consistently null|string across all entities. |
142 | 142 | $data['gid'] = empty($data['gid']) ? null : (string)$data['gid']; |
143 | 143 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return $this |
158 | 158 | * @internal |
159 | 159 | */ |
160 | - protected function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
160 | + protected function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
161 | 161 | if ($this->hasGid()) { |
162 | 162 | /** @var array $remote */ |
163 | 163 | $remote = $this->api->post($path, $data, ['fields' => static::$optFields[$field] ?? $field]); |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return string[] |
177 | 177 | */ |
178 | - public function getCacheKeys () { |
|
178 | + public function getCacheKeys() { |
|
179 | 179 | return [$this->getGid(), (string)$this]; |
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | 183 | * @return null|string |
184 | 184 | */ |
185 | - final public function getGid (): ?string { |
|
185 | + final public function getGid(): ?string { |
|
186 | 186 | return $this->data['gid'] ?? null; |
187 | 187 | } |
188 | 188 | |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - final public function getResourceType (): string { |
|
194 | + final public function getResourceType(): string { |
|
195 | 195 | return $this::TYPE; |
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * @return bool |
200 | 200 | */ |
201 | - final public function hasGid (): bool { |
|
201 | + final public function hasGid(): bool { |
|
202 | 202 | return isset($this->data['gid']); |
203 | 203 | } |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $field |
210 | 210 | * @return $this |
211 | 211 | */ |
212 | - public function reload (string $field = null) { |
|
212 | + public function reload(string $field = null) { |
|
213 | 213 | if (!$this->hasGid()) { |
214 | 214 | throw new LogicException(static::class . " has no GID, it can't be reloaded."); |
215 | 215 | } |
@@ -107,8 +107,7 @@ discard block |
||
107 | 107 | protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
108 | 108 | if ($this->hasGid()) { |
109 | 109 | return $this->_setWithPost($rmPath, $data, $field); |
110 | - } |
|
111 | - elseif (is_array($diff)) { |
|
110 | + } elseif (is_array($diff)) { |
|
112 | 111 | return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
113 | 112 | } |
114 | 113 | return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff))); |
@@ -124,11 +123,9 @@ discard block |
||
124 | 123 | protected function _save (string $dir = null) { |
125 | 124 | if (isset($dir)) { |
126 | 125 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
127 | - } |
|
128 | - elseif ($this->isDiff()) { |
|
126 | + } elseif ($this->isDiff()) { |
|
129 | 127 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
130 | - } |
|
131 | - else { |
|
128 | + } else { |
|
132 | 129 | return $this; |
133 | 130 | } |
134 | 131 | /** @var array $remote */ |
@@ -217,11 +214,9 @@ discard block |
||
217 | 214 | $optField = static::$optFields[$field] ?? $field; |
218 | 215 | $value = $this->api->get($this, [], ['fields' => $optField])[$field] ?? null; |
219 | 216 | $this->_setMapped($field, $value); |
220 | - } |
|
221 | - elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
217 | + } elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
222 | 218 | $this->_setData($remote); |
223 | - } |
|
224 | - else { // deleted upstream. |
|
219 | + } else { // deleted upstream. |
|
225 | 220 | $this->api->getCache()->remove($this->getCacheKeys()); |
226 | 221 | throw new RuntimeException("{$this} was deleted upstream."); |
227 | 222 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | 'new_value*' => Event::GRAPH |
31 | 31 | ]; |
32 | 32 | |
33 | - protected function _setMapped (string $field, $value): void { |
|
33 | + protected function _setMapped(string $field, $value): void { |
|
34 | 34 | if (!is_array($value)) { |
35 | 35 | $this->data[$field] = $value; |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return null|number|string|User|Project|Section|Task|FieldEntry|Attachment|Story|Like |
44 | 44 | */ |
45 | - public function getValue () { |
|
45 | + public function getValue() { |
|
46 | 46 | $key = [ |
47 | 47 | 'added' => 'added_value', |
48 | 48 | 'removed' => 'removed_value', |
@@ -33,8 +33,7 @@ |
||
33 | 33 | protected function _setMapped (string $field, $value): void { |
34 | 34 | if (!is_array($value)) { |
35 | 35 | $this->data[$field] = $value; |
36 | - } |
|
37 | - else { |
|
36 | + } else { |
|
38 | 37 | parent::_setMapped($field, $value); |
39 | 38 | } |
40 | 39 | } |