@@ -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 |
@@ -31,18 +31,18 @@ |
||
31 | 31 | 'workspace' => Workspace::class |
32 | 32 | ]; |
33 | 33 | |
34 | - final public function __toString (): string { |
|
34 | + final public function __toString(): string { |
|
35 | 35 | return "tags/{$this->getGid()}"; |
36 | 36 | } |
37 | 37 | |
38 | - final protected function _getDir (): string { |
|
38 | + final protected function _getDir(): string { |
|
39 | 39 | return 'tags'; |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @return Task[] |
44 | 44 | */ |
45 | - public function getTasks () { |
|
45 | + public function getTasks() { |
|
46 | 46 | return $this->loadAll(Task::class, "{$this}/tasks"); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -52,23 +52,23 @@ |
||
52 | 52 | * @param Project $project |
53 | 53 | * @param array $data |
54 | 54 | */ |
55 | - public function __construct (Project $project, array $data = []) { |
|
55 | + public function __construct(Project $project, array $data = []) { |
|
56 | 56 | parent::__construct($project, $data); |
57 | 57 | $this->project = $project; |
58 | 58 | } |
59 | 59 | |
60 | - final public function __toString (): string { |
|
60 | + final public function __toString(): string { |
|
61 | 61 | return "project_statuses/{$this->getGid()}"; |
62 | 62 | } |
63 | 63 | |
64 | - final protected function _getDir (): string { |
|
64 | + final protected function _getDir(): string { |
|
65 | 65 | return "{$this->project}/project_statuses"; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return Project |
70 | 70 | */ |
71 | - public function getProject () { |
|
71 | + public function getProject() { |
|
72 | 72 | return $this->project; |
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | 'project' => Project::class |
29 | 29 | ]; |
30 | 30 | |
31 | - final public function __toString (): string { |
|
31 | + final public function __toString(): string { |
|
32 | 32 | return "sections/{$this->getGid()}"; |
33 | 33 | } |
34 | 34 | |
35 | - final protected function _getDir (): string { |
|
35 | + final protected function _getDir(): string { |
|
36 | 36 | return "{$this->getProject()}/sections"; |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @return Task[] |
41 | 41 | */ |
42 | - public function getTasks () { |
|
42 | + public function getTasks() { |
|
43 | 43 | return $this->loadAll(Task::class, 'tasks', ['section' => $this->getGid()]); |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @depends after-create |
50 | 50 | * @return Task |
51 | 51 | */ |
52 | - public function newTask () { |
|
52 | + public function newTask() { |
|
53 | 53 | /** @var Task $task */ |
54 | 54 | $task = $this->factory(Task::class); |
55 | 55 | return $task->addToProject($this); |
@@ -68,8 +68,7 @@ discard block |
||
68 | 68 | $this->data[$key] = array_values(array_unique($this->data[$key])); |
69 | 69 | if ($force) { |
70 | 70 | $this->diff[$key] = true; |
71 | - } |
|
72 | - else { |
|
71 | + } else { |
|
73 | 72 | $this->api->getCache()->add($this); |
74 | 73 | } |
75 | 74 | } |
@@ -117,8 +116,7 @@ discard block |
||
117 | 116 | if (isset($key)) { |
118 | 117 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
119 | 118 | $this->_setMapped($key, $value); |
120 | - } |
|
121 | - else { |
|
119 | + } else { |
|
122 | 120 | $this->_setData($this->api->get($this, [], ['expand' => 'this'])); |
123 | 121 | } |
124 | 122 | $this->api->getCache()->add($this); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - abstract public function __toString (): string; |
|
19 | + abstract public function __toString(): string; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Maps lazy-loaded / reloadable fields to their proper expanded field expression. |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $key |
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | - protected function _get (string $key) { |
|
36 | + protected function _get(string $key) { |
|
37 | 37 | if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop |
38 | 38 | $this->reload($key); |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param bool $force |
49 | 49 | * @return $this |
50 | 50 | */ |
51 | - protected function _merge (string $key, array $entities, $force = false) { |
|
51 | + protected function _merge(string $key, array $entities, $force = false) { |
|
52 | 52 | if ($force or isset($this->data[$key])) { |
53 | 53 | foreach ($entities as $entity) { |
54 | 54 | $this->data[$key][] = $entity; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param AbstractEntity[] $entities |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - protected function _remove (string $key, array $entities) { |
|
74 | + protected function _remove(string $key, array $entities) { |
|
75 | 75 | if (isset($this->data[$key])) { |
76 | 76 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities)); |
77 | 77 | $this->api->getCache()->add($this); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param AbstractEntity $entity |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - public function merge (AbstractEntity $entity) { |
|
88 | + public function merge(AbstractEntity $entity) { |
|
89 | 89 | assert($entity->api); // hydrated |
90 | 90 | foreach ($entity->data as $key => $value) { |
91 | 91 | if (!array_key_exists($key, $this->data) and !isset($entity->diff[$key])) { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $key |
102 | 102 | * @return $this |
103 | 103 | */ |
104 | - public function reload (string $key = null) { |
|
104 | + public function reload(string $key = null) { |
|
105 | 105 | if (isset($key)) { |
106 | 106 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
107 | 107 | $this->_setMapped($key, $value); |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | 'task' => Task::class |
46 | 46 | ]; |
47 | 47 | |
48 | - final public function __toString (): string { |
|
48 | + final public function __toString(): string { |
|
49 | 49 | return "stories/{$this->getGid()}"; |
50 | 50 | } |
51 | 51 | |
52 | - final protected function _getDir (): string { |
|
52 | + final protected function _getDir(): string { |
|
53 | 53 | return "{$this->getTask()}/stories"; |
54 | 54 | } |
55 | 55 | |
56 | - final public function isComment (): bool { |
|
56 | + final public function isComment(): bool { |
|
57 | 57 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
58 | 58 | } |
59 | 59 | |
60 | - public function isEdited (): bool { |
|
60 | + public function isEdited(): bool { |
|
61 | 61 | return $this->_is('is_edited'); |
62 | 62 | } |
63 | 63 | |
64 | - public function isPinned (): bool { |
|
64 | + public function isPinned(): bool { |
|
65 | 65 | return $this->_is('is_pinned'); |
66 | 66 | } |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param bool $pinned |
70 | 70 | * @return $this |
71 | 71 | */ |
72 | - public function setPinned (bool $pinned) { |
|
72 | + public function setPinned(bool $pinned) { |
|
73 | 73 | return $this->_set('is_pinned', $pinned); |
74 | 74 | } |
75 | 75 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'parent' => Task::class |
33 | 33 | ]; |
34 | 34 | |
35 | - final public function __toString (): string { |
|
35 | + final public function __toString(): string { |
|
36 | 36 | return "attachments/{$this->getGid()}"; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $file |
43 | 43 | * @return $this |
44 | 44 | */ |
45 | - public function upload (string $file) { |
|
45 | + public function upload(string $file) { |
|
46 | 46 | // api returns compact version. reload. |
47 | 47 | $remote = $this->api->upload("{$this->getParent()}/attachments", $file); |
48 | 48 | $this->data['gid'] = $remote['gid']; |
@@ -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 | $this->api->post("{$workspace}/addUser", ['user' => $this->getGid()]); |
41 | 41 | $this->_merge('workspaces', [$workspace]); |
42 | 42 | return $this; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param Workspace $workspace |
47 | 47 | * @return Portfolio[] |
48 | 48 | */ |
49 | - public function getFavoritePortfolios (Workspace $workspace) { |
|
49 | + public function getFavoritePortfolios(Workspace $workspace) { |
|
50 | 50 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Workspace $workspace |
55 | 55 | * @return Project[] |
56 | 56 | */ |
57 | - public function getFavoriteProjects (Workspace $workspace) { |
|
57 | + public function getFavoriteProjects(Workspace $workspace) { |
|
58 | 58 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
59 | 59 | } |
60 | 60 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param Workspace $workspace |
63 | 63 | * @return Tag[] |
64 | 64 | */ |
65 | - public function getFavoriteTags (Workspace $workspace) { |
|
65 | + public function getFavoriteTags(Workspace $workspace) { |
|
66 | 66 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
67 | 67 | } |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param Workspace $workspace |
71 | 71 | * @return Team[] |
72 | 72 | */ |
73 | - public function getFavoriteTeams (Workspace $workspace) { |
|
73 | + public function getFavoriteTeams(Workspace $workspace) { |
|
74 | 74 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
75 | 75 | } |
76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param Workspace $workspace |
79 | 79 | * @return User[] |
80 | 80 | */ |
81 | - public function getFavoriteUsers (Workspace $workspace) { |
|
81 | + public function getFavoriteUsers(Workspace $workspace) { |
|
82 | 82 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
83 | 83 | } |
84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param Workspace $workspace |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace) { |
|
91 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace) { |
|
92 | 92 | return $this->loadAll($class, "{$this}/favorites", [ |
93 | 93 | 'resource_type' => $resourceType, |
94 | 94 | 'workspace' => $workspace->getGid() |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param Workspace $workspace |
104 | 104 | * @return Task[] |
105 | 105 | */ |
106 | - public function getIncompleteTasks (Workspace $workspace) { |
|
106 | + public function getIncompleteTasks(Workspace $workspace) { |
|
107 | 107 | return $this->loadAll(Task::class, 'tasks', [ |
108 | 108 | 'assignee' => $this->getGid(), |
109 | 109 | 'workspace' => $workspace->getGid(), |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param Workspace $workspace |
116 | 116 | * @return Portfolio[] |
117 | 117 | */ |
118 | - public function getPortfolios (Workspace $workspace) { |
|
118 | + public function getPortfolios(Workspace $workspace) { |
|
119 | 119 | return $this->loadAll(Portfolio::class, "portfolios", [ |
120 | 120 | 'workspace' => $workspace->getGid(), |
121 | 121 | 'owner' => $this->getGid() |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param Workspace $workspace |
127 | 127 | * @return TaskList |
128 | 128 | */ |
129 | - public function getTaskList (Workspace $workspace) { |
|
129 | + public function getTaskList(Workspace $workspace) { |
|
130 | 130 | return $this->load(TaskList::class, "{$this}/user_task_list", [ |
131 | 131 | 'workspace' => $workspace->getGid() |
132 | 132 | ]); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string[] $filter |
142 | 142 | * @return Task[] |
143 | 143 | */ |
144 | - public function getTasks (Workspace $workspace, array $filter = []) { |
|
144 | + public function getTasks(Workspace $workspace, array $filter = []) { |
|
145 | 145 | $filter['assignee'] = $this->getGid(); |
146 | 146 | $filter['workspace'] = $workspace->getGid(); |
147 | 147 | return $this->loadAll(Task::class, 'tasks', $filter); |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @param Workspace $organization |
152 | 152 | * @return Team[] |
153 | 153 | */ |
154 | - public function getTeams (Workspace $organization) { |
|
154 | + public function getTeams(Workspace $organization) { |
|
155 | 155 | return $this->loadAll(Team::class, "{$this}/teams", [ |
156 | 156 | 'organization' => $organization->getGid() |
157 | 157 | ]); |
158 | 158 | } |
159 | 159 | |
160 | - public function getUrl (): string { |
|
160 | + public function getUrl(): string { |
|
161 | 161 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
162 | 162 | } |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param Workspace $workspace |
166 | 166 | * @return $this |
167 | 167 | */ |
168 | - public function removeFromWorkspace (Workspace $workspace) { |
|
168 | + public function removeFromWorkspace(Workspace $workspace) { |
|
169 | 169 | $this->api->post("{$workspace}/removeUser", ['user' => $this->getGid()]); |
170 | 170 | $this->_remove('workspaces', [$workspace]); |
171 | 171 | return $this; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | 'organization' => Workspace::class |
26 | 26 | ]; |
27 | 27 | |
28 | - final public function __toString (): string { |
|
28 | + final public function __toString(): string { |
|
29 | 29 | return "teams/{$this->getGid()}"; |
30 | 30 | } |
31 | 31 | |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | * @param User $user |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function addUser (User $user) { |
|
36 | + public function addUser(User $user) { |
|
37 | 37 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
38 | 38 | return $this; |
39 | 39 | } |
40 | 40 | |
41 | - public function getUrl (): string { |
|
41 | + public function getUrl(): string { |
|
42 | 42 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return User[] |
47 | 47 | */ |
48 | - public function getUsers () { |
|
48 | + public function getUsers() { |
|
49 | 49 | return $this->loadAll(User::class, "{$this}/users"); |
50 | 50 | } |
51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param User $user |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function removeUser (User $user) { |
|
56 | + public function removeUser(User $user) { |
|
57 | 57 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
58 | 58 | return $this; |
59 | 59 | } |