@@ -46,14 +46,14 @@ |
||
46 | 46 | /** |
47 | 47 | * @return Api |
48 | 48 | */ |
49 | - public static function getApi () { |
|
49 | + public static function getApi() { |
|
50 | 50 | return static::getFacadeRoot(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @return string |
55 | 55 | */ |
56 | - public static function getFacadeAccessor () { |
|
56 | + public static function getFacadeAccessor() { |
|
57 | 57 | return AsanaServiceProvider::NAME; |
58 | 58 | } |
59 | 59 |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | */ |
42 | 42 | class Event extends Data { |
43 | 43 | |
44 | - const ACTION_CHANGED = 'changed'; // no parent |
|
45 | - const ACTION_ADDED = 'added'; // relational, no change |
|
46 | - const ACTION_REMOVED = 'removed'; // relational, no change |
|
47 | - const ACTION_DELETED = 'deleted'; // no parent or change |
|
48 | - const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
44 | + const ACTION_CHANGED = 'changed'; // no parent |
|
45 | + const ACTION_ADDED = 'added'; // relational, no change |
|
46 | + const ACTION_REMOVED = 'removed'; // relational, no change |
|
47 | + const ACTION_DELETED = 'deleted'; // no parent or change |
|
48 | + const ACTION_UNDELETED = 'undeleted'; // no parent or change |
|
49 | 49 | |
50 | 50 | const GRAPH = [ |
51 | 51 | User::TYPE => User::class, |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'user' => User::class |
64 | 64 | ]; |
65 | 65 | |
66 | - protected function _setData (array $data): void { |
|
66 | + protected function _setData(array $data): void { |
|
67 | 67 | if (isset($data['parent'])) { |
68 | 68 | $type = $data['parent']['resource_type']; |
69 | 69 | $data['parent'] = $this->_hydrate(static::GRAPH[$type], $data['parent']); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return null|Project|Section|Task |
82 | 82 | */ |
83 | - public function getParent () { |
|
83 | + public function getParent() { |
|
84 | 84 | return $this->data['parent'] ?? null; |
85 | 85 | } |
86 | 86 | |
@@ -89,42 +89,42 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return User|Project|Section|Task|CustomField|Attachment|Story|Like |
91 | 91 | */ |
92 | - public function getResource () { |
|
92 | + public function getResource() { |
|
93 | 93 | return $this->data['resource']; |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | - final public function wasAddition (): bool { |
|
99 | + final public function wasAddition(): bool { |
|
100 | 100 | return $this->getAction() === self::ACTION_ADDED; |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - final public function wasChange (): bool { |
|
106 | + final public function wasChange(): bool { |
|
107 | 107 | return $this->getAction() === self::ACTION_CHANGED; |
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - final public function wasDeletion (): bool { |
|
113 | + final public function wasDeletion(): bool { |
|
114 | 114 | return $this->getAction() === self::ACTION_DELETED; |
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @return bool |
119 | 119 | */ |
120 | - final public function wasRemoval (): bool { |
|
120 | + final public function wasRemoval(): bool { |
|
121 | 121 | return $this->getAction() === self::ACTION_REMOVED; |
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | - final public function wasUndeletion (): bool { |
|
127 | + final public function wasUndeletion(): bool { |
|
128 | 128 | return $this->getAction() === self::ACTION_UNDELETED; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param null|string|DateTimeInterface $date |
23 | 23 | * @return $this |
24 | 24 | */ |
25 | - private function _setYmd (string $field, $date) { |
|
25 | + private function _setYmd(string $field, $date) { |
|
26 | 26 | if ($date instanceof DateTimeInterface) { |
27 | 27 | $date = $date->format('Y-m-d'); |
28 | 28 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param null|string|DateTimeInterface $date |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function setDueOn ($date) { |
|
36 | + public function setDueOn($date) { |
|
37 | 37 | return $this->_setYmd('due_on', $date); |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param null|string|DateTimeInterface $date |
42 | 42 | * @return $this |
43 | 43 | */ |
44 | - public function setStartOn ($date) { |
|
44 | + public function setStartOn($date) { |
|
45 | 45 | return $this->_setYmd('start_on', $date); |
46 | 46 | } |
47 | 47 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param array $diff |
20 | 20 | * @return $this |
21 | 21 | */ |
22 | - private function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
22 | + private function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
23 | 23 | if ($this->hasGid()) { |
24 | 24 | return $this->_setWithPost($addPath, $data, $field); |
25 | 25 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array|Closure $diff An array to diff, or a filter closure. |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - private function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
36 | + private function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
37 | 37 | if ($this->hasGid()) { |
38 | 38 | return $this->_setWithPost($rmPath, $data, $field); |
39 | 39 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return $this |
54 | 54 | * @internal |
55 | 55 | */ |
56 | - private function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
56 | + private function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
57 | 57 | if ($this->hasGid()) { |
58 | 58 | /** @var array $remote */ |
59 | 59 | $remote = $this->api->post($path, $data, ['fields' => static::OPT_FIELDS[$field] ?? $field]); |
@@ -36,8 +36,7 @@ |
||
36 | 36 | private function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
37 | 37 | if ($this->hasGid()) { |
38 | 38 | return $this->_setWithPost($rmPath, $data, $field); |
39 | - } |
|
40 | - elseif (is_array($diff)) { |
|
39 | + } elseif (is_array($diff)) { |
|
41 | 40 | return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
42 | 41 | } |
43 | 42 | return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff))); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected $key; |
42 | 42 | |
43 | - protected function _setData (array $data): void { |
|
43 | + protected function _setData(array $data): void { |
|
44 | 44 | $this->key = [ |
45 | 45 | Event::ACTION_ADDED => 'added_value', |
46 | 46 | Event::ACTION_REMOVED => 'removed_value', |
@@ -67,35 +67,35 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return null|User|Project|Section|Task|FieldEntry|Attachment|Story|Like |
69 | 69 | */ |
70 | - public function getPayload () { |
|
70 | + public function getPayload() { |
|
71 | 71 | return $this->data[$this->key]; |
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - final public function hasPayload (): bool { |
|
77 | + final public function hasPayload(): bool { |
|
78 | 78 | return isset($this->data[$this->key]); |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | - final public function wasAddition (): bool { |
|
84 | + final public function wasAddition(): bool { |
|
85 | 85 | return $this->getAction() === Event::ACTION_ADDED; |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - final public function wasRemoval (): bool { |
|
91 | + final public function wasRemoval(): bool { |
|
92 | 92 | return $this->getAction() === Event::ACTION_REMOVED; |
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @return bool |
97 | 97 | */ |
98 | - final public function wasValue (): bool { |
|
98 | + final public function wasValue(): bool { |
|
99 | 99 | return $this->getAction() === Event::ACTION_CHANGED; |
100 | 100 | } |
101 | 101 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param null|string $token Updated to the new token. |
25 | 25 | * @return Event[] |
26 | 26 | */ |
27 | - public function getEvents (?string &$token) { |
|
27 | + public function getEvents(?string &$token) { |
|
28 | 28 | try { |
29 | 29 | /** @var array $remote Asana throws 400 for missing entities. */ |
30 | 30 | $remote = $this->api->call('GET', 'events?' . http_build_query([ |
@@ -32,8 +32,7 @@ |
||
32 | 32 | 'sync' => $token, |
33 | 33 | 'opt_expand' => 'this' |
34 | 34 | ])); |
35 | - } |
|
36 | - catch (AsanaError $error) { |
|
35 | + } catch (AsanaError $error) { |
|
37 | 36 | if ($error->is(412)) { |
38 | 37 | $remote = $error->asResponse(); |
39 | 38 | if (!isset($token)) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - final public function isActive (): bool { |
|
43 | + final public function isActive(): bool { |
|
44 | 44 | return $this->getStatus() === self::STATUS_ACTIVE; |
45 | 45 | } |
46 | 46 | |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return bool |
51 | 51 | */ |
52 | - final public function isDone (): bool { |
|
52 | + final public function isDone(): bool { |
|
53 | 53 | return $this->isSuccessful() or $this->isFailed(); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return bool |
58 | 58 | */ |
59 | - final public function isDuplicatingProject (): bool { |
|
59 | + final public function isDuplicatingProject(): bool { |
|
60 | 60 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_PROJECT; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @return bool |
65 | 65 | */ |
66 | - final public function isDuplicatingTask (): bool { |
|
66 | + final public function isDuplicatingTask(): bool { |
|
67 | 67 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_TASK; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - final public function isFailed (): bool { |
|
75 | + final public function isFailed(): bool { |
|
76 | 76 | return $this->getStatus() === self::STATUS_FAIL; |
77 | 77 | } |
78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | - final public function isQueued (): bool { |
|
84 | + final public function isQueued(): bool { |
|
85 | 85 | return $this->getStatus() === self::STATUS_QUEUED; |
86 | 86 | } |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool |
92 | 92 | */ |
93 | - final public function isSuccessful (): bool { |
|
93 | + final public function isSuccessful(): bool { |
|
94 | 94 | return $this->getStatus() === self::STATUS_SUCCESS; |
95 | 95 | } |
96 | 96 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param callable $spinner `fn( Job $this ): void` |
103 | 103 | * @return $this |
104 | 104 | */ |
105 | - public function wait (callable $spinner = null) { |
|
105 | + public function wait(callable $spinner = null) { |
|
106 | 106 | while (!$this->isDone()) { |
107 | 107 | if ($spinner) { |
108 | 108 | call_user_func($spinner, $this); |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | * @param array $filter |
37 | 37 | * @return Traversable|Task[] |
38 | 38 | */ |
39 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
39 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
40 | 40 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
41 | 41 | } |
42 | 42 | |
43 | - public function getPoolKeys () { |
|
43 | + public function getPoolKeys() { |
|
44 | 44 | $keys = parent::getPoolKeys(); |
45 | 45 | |
46 | 46 | /** @see User::getTaskList() */ |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $filter |
58 | 58 | * @return Task[] |
59 | 59 | */ |
60 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
60 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
61 | 61 | return iterator_to_array($this->getIterator($filter)); |
62 | 62 | } |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param array $apiFilter Given to the API to reduce network load. |
67 | 67 | * @return Task[] |
68 | 68 | */ |
69 | - public function selectTasks (callable $filter, array $apiFilter = Task::GET_INCOMPLETE) { |
|
69 | + public function selectTasks(callable $filter, array $apiFilter = Task::GET_INCOMPLETE) { |
|
70 | 70 | return $this->_select($this->getIterator($apiFilter), $filter); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param array $filter |
44 | 44 | * @return Traversable|Task[] |
45 | 45 | */ |
46 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
46 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
47 | 47 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
48 | 48 | } |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param array $filter |
52 | 52 | * @return Task[] |
53 | 53 | */ |
54 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
54 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
55 | 55 | return iterator_to_array($this->getIterator($filter)); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | \ No newline at end of file |