@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param Api|Data $caller |
| 47 | 47 | * @param array $data |
| 48 | 48 | */ |
| 49 | - public function __construct ($caller, array $data = []) { |
|
| 49 | + public function __construct($caller, array $data = []) { |
|
| 50 | 50 | if ($caller instanceof self) { |
| 51 | 51 | $this->api = $caller->api; |
| 52 | 52 | } |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * @param array $args |
| 70 | 70 | * @return mixed |
| 71 | 71 | */ |
| 72 | - public function __call (string $method, array $args) { |
|
| 72 | + public function __call(string $method, array $args) { |
|
| 73 | 73 | static $magic = []; |
| 74 | - if (!$call =& $magic[$method]) { |
|
| 74 | + if (!$call = & $magic[$method]) { |
|
| 75 | 75 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
| 76 | 76 | if ('_select' !== $call[1] = '_' . $call[1]) { // _select() calls getters |
| 77 | 77 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return array |
| 87 | 87 | * @internal pool, `var_export()` |
| 88 | 88 | */ |
| 89 | - final public function __debugInfo (): array { |
|
| 89 | + final public function __debugInfo(): array { |
|
| 90 | 90 | return $this->data; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return null|Data|mixed |
| 96 | 96 | * @internal for `array_column()` |
| 97 | 97 | */ |
| 98 | - final public function __get ($field) { |
|
| 98 | + final public function __get($field) { |
|
| 99 | 99 | return $this->_get($field); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return bool |
| 105 | 105 | * @internal for `array_column()` |
| 106 | 106 | */ |
| 107 | - final public function __isset ($field) { |
|
| 107 | + final public function __isset($field) { |
|
| 108 | 108 | return true; // fields may be lazy-loaded or coalesced to null. |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param string $field |
| 117 | 117 | * @return mixed |
| 118 | 118 | */ |
| 119 | - protected function _get (string $field) { |
|
| 119 | + protected function _get(string $field) { |
|
| 120 | 120 | return $this->data[$field] ?? null; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $field |
| 132 | 132 | * @return bool |
| 133 | 133 | */ |
| 134 | - protected function _has (string $field): bool { |
|
| 134 | + protected function _has(string $field): bool { |
|
| 135 | 135 | $value = $this->_get($field); |
| 136 | 136 | if (isset($value)) { |
| 137 | 137 | if (is_countable($value)) { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param mixed $item |
| 150 | 150 | * @return mixed |
| 151 | 151 | */ |
| 152 | - protected function _hydrate (string $class, $item) { |
|
| 152 | + protected function _hydrate(string $class, $item) { |
|
| 153 | 153 | if (!isset($item) or $item instanceof self) { |
| 154 | 154 | return $item; |
| 155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param string $field |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - protected function _is (string $field): bool { |
|
| 181 | + protected function _is(string $field): bool { |
|
| 182 | 182 | return (bool)$this->_get($field); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $args |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | - protected function _select ($subject, callable $filter, ...$args) { |
|
| 199 | + protected function _select($subject, callable $filter, ...$args) { |
|
| 200 | 200 | if (is_string($subject)) { |
| 201 | 201 | $subject = $this->{'get' . $subject}(...$args) ?? []; |
| 202 | 202 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param mixed $value |
| 219 | 219 | * @return $this |
| 220 | 220 | */ |
| 221 | - protected function _set (string $field, $value) { |
|
| 221 | + protected function _set(string $field, $value) { |
|
| 222 | 222 | $this->data[$field] = $value; |
| 223 | 223 | $this->diff[$field] = true; |
| 224 | 224 | return $this; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param array $data |
| 231 | 231 | */ |
| 232 | - protected function _setData (array $data): void { |
|
| 232 | + protected function _setData(array $data): void { |
|
| 233 | 233 | $this->data = $this->diff = []; |
| 234 | 234 | foreach ($data as $field => $value) { |
| 235 | 235 | $this->_setField($field, $value); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param string $field |
| 243 | 243 | * @param mixed $value |
| 244 | 244 | */ |
| 245 | - protected function _setField (string $field, $value): void { |
|
| 245 | + protected function _setField(string $field, $value): void { |
|
| 246 | 246 | if (isset(static::MAP[$field])) { |
| 247 | 247 | $class = static::MAP[$field]; |
| 248 | 248 | if (is_array($class)) { |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return bool |
| 265 | 265 | */ |
| 266 | - final public function isDiff (): bool { |
|
| 266 | + final public function isDiff(): bool { |
|
| 267 | 267 | return (bool)$this->diff; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @return array |
| 272 | 272 | */ |
| 273 | - public function jsonSerialize (): array { |
|
| 273 | + public function jsonSerialize(): array { |
|
| 274 | 274 | $data = $this->toArray(); |
| 275 | 275 | ksort($data); |
| 276 | 276 | return $data; |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | - public function serialize (): string { |
|
| 285 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
| 284 | + public function serialize(): string { |
|
| 285 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param bool $diff |
| 292 | 292 | * @return array |
| 293 | 293 | */ |
| 294 | - public function toArray (bool $diff = false): array { |
|
| 294 | + public function toArray(bool $diff = false): array { |
|
| 295 | 295 | $dehydrate = function($each) use (&$dehydrate, $diff) { |
| 296 | 296 | // convert entities to gids |
| 297 | 297 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | /** |
| 318 | 318 | * @param $serialized |
| 319 | 319 | */ |
| 320 | - public function unserialize ($serialized): void { |
|
| 320 | + public function unserialize($serialized): void { |
|
| 321 | 321 | $this->data = json_decode($serialized, true); |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | \ 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]); |
@@ -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([ |
@@ -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 |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * @param Project $project |
| 52 | 52 | * @param array $data |
| 53 | 53 | */ |
| 54 | - public function __construct (Project $project, array $data = []) { |
|
| 54 | + public function __construct(Project $project, array $data = []) { |
|
| 55 | 55 | $this->parent = $project; |
| 56 | 56 | parent::__construct($project, $data); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _setData (array $data): void { |
|
| 59 | + protected function _setData(array $data): void { |
|
| 60 | 60 | // redundant, prefer created_by |
| 61 | 61 | unset($data['author']); |
| 62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @return Project |
| 68 | 68 | */ |
| 69 | - public function getProject () { |
|
| 69 | + public function getProject() { |
|
| 70 | 70 | return $this->parent; |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |