@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - final public function __toString (): string { |
|
42 | + final public function __toString(): string { |
|
43 | 43 | return "jobs/{$this->getGid()}"; |
44 | 44 | } |
45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return bool |
50 | 50 | */ |
51 | - final public function isActive (): bool { |
|
51 | + final public function isActive(): bool { |
|
52 | 52 | return $this->getStatus() === self::STATUS_ACTIVE; |
53 | 53 | } |
54 | 54 | |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - final public function isDone (): bool { |
|
60 | + final public function isDone(): bool { |
|
61 | 61 | return $this->isSuccessful() or $this->isFailed(); |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - final public function isDuplicatingProject (): bool { |
|
67 | + final public function isDuplicatingProject(): bool { |
|
68 | 68 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_PROJECT; |
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - final public function isDuplicatingTask (): bool { |
|
74 | + final public function isDuplicatingTask(): bool { |
|
75 | 75 | return $this->getResourceSubtype() === self::TYPE_DUPLICATE_TASK; |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - final public function isFailed (): bool { |
|
83 | + final public function isFailed(): bool { |
|
84 | 84 | return $this->getStatus() === self::STATUS_FAIL; |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - final public function isQueued (): bool { |
|
92 | + final public function isQueued(): bool { |
|
93 | 93 | return $this->getStatus() === self::STATUS_QUEUED; |
94 | 94 | } |
95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - final public function isSuccessful (): bool { |
|
101 | + final public function isSuccessful(): bool { |
|
102 | 102 | return $this->getStatus() === self::STATUS_SUCCESS; |
103 | 103 | } |
104 | 104 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param callable $spinner `fn( Job $this ): void` |
111 | 111 | * @return $this |
112 | 112 | */ |
113 | - public function wait (callable $spinner = null) { |
|
113 | + public function wait(callable $spinner = null) { |
|
114 | 114 | while (!$this->isDone()) { |
115 | 115 | if ($spinner) { |
116 | 116 | call_user_func($spinner, $this); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - final public function __toString (): string { |
|
39 | + final public function __toString(): string { |
|
40 | 40 | return "user_task_lists/{$this->getGid()}"; |
41 | 41 | } |
42 | 42 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param array $filter |
45 | 45 | * @return Traversable|Task[] |
46 | 46 | */ |
47 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
47 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
48 | 48 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
49 | 49 | } |
50 | 50 | |
51 | - public function getPoolKeys () { |
|
51 | + public function getPoolKeys() { |
|
52 | 52 | $keys = parent::getPoolKeys(); |
53 | 53 | |
54 | 54 | /** @see User::getTaskList() */ |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $filter |
66 | 66 | * @return Task[] |
67 | 67 | */ |
68 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
68 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
69 | 69 | return iterator_to_array($this->getIterator($filter)); |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $apiFilter Given to the API to reduce network load. |
75 | 75 | * @return Task[] |
76 | 76 | */ |
77 | - public function selectTasks (callable $filter, array $apiFilter = Task::GET_INCOMPLETE) { |
|
77 | + public function selectTasks(callable $filter, array $apiFilter = Task::GET_INCOMPLETE) { |
|
78 | 78 | return $this->_select($this->getIterator($apiFilter), $filter); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - final public function __toString (): string { |
|
39 | + final public function __toString(): string { |
|
40 | 40 | return "webhooks/{$this->getGid()}"; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - final protected function _getDir (): string { |
|
48 | + final protected function _getDir(): string { |
|
49 | 49 | return 'webhooks'; |
50 | 50 | } |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $target |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function create ($resource, string $target) { |
|
57 | + public function create($resource, string $target) { |
|
58 | 58 | $this->_set('resource', $resource); |
59 | 59 | $this->_set('target', $target); |
60 | 60 | return $this->_create(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return string |
53 | 53 | */ |
54 | - final public function __toString (): string { |
|
54 | + final public function __toString(): string { |
|
55 | 55 | return "stories/{$this->getGid()}"; |
56 | 56 | } |
57 | 57 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - final protected function _getDir (): string { |
|
63 | + final protected function _getDir(): string { |
|
64 | 64 | return "{$this->getTarget()}/stories"; |
65 | 65 | } |
66 | 66 | |
67 | - protected function _setData (array $data): void { |
|
67 | + protected function _setData(array $data): void { |
|
68 | 68 | // hearts were deprecated for likes |
69 | 69 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
70 | 70 | |
@@ -74,49 +74,49 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - final public function isAssignment (): bool { |
|
77 | + final public function isAssignment(): bool { |
|
78 | 78 | return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | - final public function isComment (): bool { |
|
84 | + final public function isComment(): bool { |
|
85 | 85 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - final public function isDueDate (): bool { |
|
91 | + final public function isDueDate(): bool { |
|
92 | 92 | return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @return bool |
97 | 97 | */ |
98 | - final public function isEdited (): bool { |
|
98 | + final public function isEdited(): bool { |
|
99 | 99 | return $this->_is('is_edited'); |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @return bool |
104 | 104 | */ |
105 | - final public function isFromApi (): bool { |
|
105 | + final public function isFromApi(): bool { |
|
106 | 106 | return $this->getSource() === 'api'; |
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return bool |
111 | 111 | */ |
112 | - final public function isFromWeb (): bool { |
|
112 | + final public function isFromWeb(): bool { |
|
113 | 113 | return $this->getSource() === 'web'; |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - final public function isPinned (): bool { |
|
119 | + final public function isPinned(): bool { |
|
120 | 120 | return $this->_is('is_pinned'); |
121 | 121 | } |
122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param bool $pinned |
125 | 125 | * @return $this |
126 | 126 | */ |
127 | - final public function setPinned (bool $pinned) { |
|
127 | + final public function setPinned(bool $pinned) { |
|
128 | 128 | return $this->_set('is_pinned', $pinned); |
129 | 129 | } |
130 | 130 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "attachments/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $file |
51 | 51 | * @return $this |
52 | 52 | */ |
53 | - public function upload (string $file) { |
|
53 | + public function upload(string $file) { |
|
54 | 54 | // api returns compact version. reload. |
55 | 55 | $remote = $this->api->upload($file, "{$this->getParent()}/attachments"); |
56 | 56 | $this->data['gid'] = $remote['gid']; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param Change|FieldEntries $caller |
32 | 32 | * @param array $data |
33 | 33 | */ |
34 | - public function __construct ($caller, array $data = []) { |
|
34 | + public function __construct($caller, array $data = []) { |
|
35 | 35 | $this->caller = $caller; |
36 | 36 | parent::__construct($caller, $data); |
37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function __toString (): string { |
|
42 | + public function __toString(): string { |
|
43 | 43 | if ($this->isEnum()) { |
44 | 44 | return (string)$this->getCurrentOptionName(); |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param array $data |
53 | 53 | */ |
54 | - protected function _setData (array $data): void { |
|
54 | + protected function _setData(array $data): void { |
|
55 | 55 | if (isset($data['resource_subtype'])) { // sentinel for bloat |
56 | 56 | $tiny = array_intersect_key($data, array_flip([ |
57 | 57 | 'gid', |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * @param null|string $value |
78 | 78 | * @return null|string |
79 | 79 | */ |
80 | - protected function _toEnumOptionGid ($value) { |
|
80 | + protected function _toEnumOptionGid($value) { |
|
81 | 81 | return $this->getEnumOptionValues()[$value] ?? $value; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function getCurrentOptionName () { |
|
87 | + public function getCurrentOptionName() { |
|
88 | 88 | return $this->getEnumOptionNames()[$this->getValue()]; |
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @return CustomField |
93 | 93 | */ |
94 | - public function getCustomField () { |
|
94 | + public function getCustomField() { |
|
95 | 95 | return $this->api->getCustomField($this->getGid()); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return string[] |
102 | 102 | */ |
103 | - public function getEnumOptionNames () { |
|
103 | + public function getEnumOptionNames() { |
|
104 | 104 | static $names = []; // shared |
105 | 105 | $gid = $this->data['gid']; |
106 | 106 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string[] |
113 | 113 | */ |
114 | - public function getEnumOptionValues () { |
|
114 | + public function getEnumOptionValues() { |
|
115 | 115 | static $values = []; // shared |
116 | 116 | $gid = $this->data['gid']; |
117 | 117 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return null|number|string |
122 | 122 | */ |
123 | - public function getValue () { |
|
123 | + public function getValue() { |
|
124 | 124 | $type = $this->data['type']; |
125 | 125 | if ($type === CustomField::TYPE_ENUM) { |
126 | 126 | return $this->data['enum_value']['gid'] ?? null; |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - final public function isEnum (): bool { |
|
134 | + final public function isEnum(): bool { |
|
135 | 135 | return $this->getType() === CustomField::TYPE_ENUM; |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @return bool |
140 | 140 | */ |
141 | - final public function isNumber (): bool { |
|
141 | + final public function isNumber(): bool { |
|
142 | 142 | return $this->getType() === CustomField::TYPE_NUMBER; |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - final public function isText (): bool { |
|
148 | + final public function isText(): bool { |
|
149 | 149 | return $this->getType() === CustomField::TYPE_TEXT; |
150 | 150 | } |
151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param null|number|string $value |
154 | 154 | * @return $this |
155 | 155 | */ |
156 | - public function setValue ($value) { |
|
156 | + public function setValue($value) { |
|
157 | 157 | if ($this->caller instanceof FieldEntries) { // read-only if the entry is in an event change. |
158 | 158 | $type = $this->data['type']; |
159 | 159 | $this->diff["{$type}_value"] = true; |
@@ -160,8 +160,7 @@ |
||
160 | 160 | $this->caller->__set($this->data['gid'], true); |
161 | 161 | if ($type === CustomField::TYPE_ENUM) { |
162 | 162 | $this->data['enum_value']['gid'] = $this->_toEnumOptionGid($value); |
163 | - } |
|
164 | - else { |
|
163 | + } else { |
|
165 | 164 | $this->data["{$type}_value"] = $value; |
166 | 165 | } |
167 | 166 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | 'user' => User::class |
19 | 19 | ]; |
20 | 20 | |
21 | - protected function _setData (array $data): void { |
|
21 | + protected function _setData(array $data): void { |
|
22 | 22 | // useless. likes aren't entities. |
23 | 23 | unset($data['gid'], $data['resource_type']); |
24 | 24 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param Task $task |
54 | 54 | * @param array $data |
55 | 55 | */ |
56 | - public function __construct (Task $task, array $data = []) { |
|
56 | + public function __construct(Task $task, array $data = []) { |
|
57 | 57 | $this->task = $task; |
58 | 58 | parent::__construct($task, $data); |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $unused |
64 | 64 | * @internal called by an entry |
65 | 65 | */ |
66 | - public function __set (string $gid, $unused) { |
|
66 | + public function __set(string $gid, $unused) { |
|
67 | 67 | $this->diff[$gid] = true; |
68 | 68 | $this->task->diff['custom_fields'] = true; |
69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param mixed $unused |
73 | 73 | * @internal called by the task |
74 | 74 | */ |
75 | - public function __unset ($unused) { |
|
75 | + public function __unset($unused) { |
|
76 | 76 | $this->diff = []; |
77 | 77 | foreach ($this->data as $entry) { |
78 | 78 | $entry->diff = []; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string $i |
84 | 84 | * @param array $data |
85 | 85 | */ |
86 | - protected function _setField (string $i, $data): void { |
|
86 | + protected function _setField(string $i, $data): void { |
|
87 | 87 | /** @var FieldEntry $entry */ |
88 | 88 | $entry = $this->api->factory($this, FieldEntry::class, $data); |
89 | 89 | $gid = $entry->getGid(); |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @param string $offset |
98 | 98 | * @return string |
99 | 99 | */ |
100 | - protected function _toGid (string $offset): string { |
|
100 | + protected function _toGid(string $offset): string { |
|
101 | 101 | return $this->gids[$offset] ?? $offset; |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function count () { |
|
107 | + public function count() { |
|
108 | 108 | return count($this->data); |
109 | 109 | } |
110 | 110 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param $fieldGid |
113 | 113 | * @return FieldEntry |
114 | 114 | */ |
115 | - public function getField ($fieldGid) { |
|
115 | + public function getField($fieldGid) { |
|
116 | 116 | return $this->data[$fieldGid]; |
117 | 117 | } |
118 | 118 | |
@@ -120,41 +120,41 @@ discard block |
||
120 | 120 | * @param string $name |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function getGid (string $name): string { |
|
123 | + public function getGid(string $name): string { |
|
124 | 124 | return $this->gids[$name]; |
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @return string[] |
129 | 129 | */ |
130 | - public function getGids () { |
|
130 | + public function getGids() { |
|
131 | 131 | return $this->gids; |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | 135 | * @return Generator |
136 | 136 | */ |
137 | - public function getIterator () { |
|
137 | + public function getIterator() { |
|
138 | 138 | foreach ($this->data as $gid => $field) { |
139 | 139 | yield $gid => $field->getValue(); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - public function getName (string $fieldGid) { |
|
143 | + public function getName(string $fieldGid) { |
|
144 | 144 | return $this->names[$fieldGid]; |
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * @return string[] |
149 | 149 | */ |
150 | - public function getNames () { |
|
150 | + public function getNames() { |
|
151 | 151 | return $this->names; |
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * @return array |
156 | 156 | */ |
157 | - public function getValues () { |
|
157 | + public function getValues() { |
|
158 | 158 | return iterator_to_array($this); |
159 | 159 | } |
160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $offset |
163 | 163 | * @return bool |
164 | 164 | */ |
165 | - public function offsetExists ($offset) { |
|
165 | + public function offsetExists($offset) { |
|
166 | 166 | return isset($this->data[$this->_toGid($offset)]); |
167 | 167 | } |
168 | 168 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string $offset |
171 | 171 | * @return null|number|string |
172 | 172 | */ |
173 | - public function offsetGet ($offset) { |
|
173 | + public function offsetGet($offset) { |
|
174 | 174 | return $this->data[$this->_toGid($offset)]->getValue(); |
175 | 175 | } |
176 | 176 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string $offset |
179 | 179 | * @param null|number|string $value |
180 | 180 | */ |
181 | - public function offsetSet ($offset, $value) { |
|
181 | + public function offsetSet($offset, $value) { |
|
182 | 182 | $this->data[$this->_toGid($offset)]->setValue($value); |
183 | 183 | } |
184 | 184 | |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param string $offset |
189 | 189 | */ |
190 | - public function offsetUnset ($offset) { |
|
190 | + public function offsetUnset($offset) { |
|
191 | 191 | $this->offsetSet($offset, null); |
192 | 192 | } |
193 | 193 | |
194 | - public function toArray (bool $diff = false): array { |
|
194 | + public function toArray(bool $diff = false): array { |
|
195 | 195 | if ($diff) { |
196 | 196 | return array_map(function(FieldEntry $entry) { |
197 | 197 | return $entry->getValue(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param Task $task |
31 | 31 | * @param array $data |
32 | 32 | */ |
33 | - public function __construct (Task $task, array $data = []) { |
|
33 | + public function __construct(Task $task, array $data = []) { |
|
34 | 34 | $this->task = $task; |
35 | 35 | parent::__construct($task, $data); |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param mixed $value |
43 | 43 | * @return $this |
44 | 44 | */ |
45 | - protected function _set (string $field, $value) { |
|
45 | + protected function _set(string $field, $value) { |
|
46 | 46 | $this->task->diff['external'] = true; |
47 | 47 | return parent::_set($field, $value); |
48 | 48 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return null|bool|number|string|array |
54 | 54 | */ |
55 | - public function getDataJsonDecoded () { |
|
55 | + public function getDataJsonDecoded() { |
|
56 | 56 | if (strlen($data = $this->getData())) { |
57 | - return json_decode($data, true, 512, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
57 | + return json_decode($data, true, 512, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
58 | 58 | } |
59 | 59 | return null; |
60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param mixed $data |
67 | 67 | * @return $this |
68 | 68 | */ |
69 | - public function setDataJsonEncoded ($data) { |
|
69 | + public function setDataJsonEncoded($data) { |
|
70 | 70 | if (isset($data)) { |
71 | 71 | return $this->setData(json_encode($data, JSON_THROW_ON_ERROR)); |
72 | 72 | } |