@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @param PSR16 $psr |
| 35 | 35 | */ |
| 36 | - public function __construct (PSR16 $psr) { |
|
| 36 | + public function __construct(PSR16 $psr) { |
|
| 37 | 37 | $this->psr = $psr; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param AbstractEntity $entity |
| 42 | 42 | * @throws CacheException |
| 43 | 43 | */ |
| 44 | - protected function _add (AbstractEntity $entity): void { |
|
| 44 | + protected function _add(AbstractEntity $entity): void { |
|
| 45 | 45 | $this->psr->set("asana/{$entity->getGid()}", $entity, $this->_getTtl($entity)); |
| 46 | 46 | parent::_add($entity); |
| 47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string[] $keys |
| 52 | 52 | * @throws CacheException |
| 53 | 53 | */ |
| 54 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
| 54 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
| 55 | 55 | $gid = $entity->getGid(); |
| 56 | 56 | $ttl = $this->_getTtl($entity); |
| 57 | 57 | foreach ($keys as $key) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return null|AbstractEntity |
| 69 | 69 | * @throws CacheException |
| 70 | 70 | */ |
| 71 | - protected function _get (string $key, $caller) { |
|
| 71 | + protected function _get(string $key, $caller) { |
|
| 72 | 72 | if (!$entity = parent::_get($key, $caller) and $entity = $this->psr->get("asana/{$key}")) { |
| 73 | 73 | if (is_string($entity)) { // gid ref |
| 74 | 74 | if (!$entity = $this->_get($entity, $caller)) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param AbstractEntity $entity |
| 89 | 89 | * @return int |
| 90 | 90 | */ |
| 91 | - protected function _getTtl (AbstractEntity $entity): int { |
|
| 91 | + protected function _getTtl(AbstractEntity $entity): int { |
|
| 92 | 92 | if ($entity instanceof ImmutableInterface) { |
| 93 | 93 | return strtotime('tomorrow') - time(); |
| 94 | 94 | } |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @return bool |
| 101 | 101 | * @throws CacheException |
| 102 | 102 | */ |
| 103 | - protected function _has (string $key): bool { |
|
| 103 | + protected function _has(string $key): bool { |
|
| 104 | 104 | return parent::_has($key) or $this->psr->has("asana/{$key}"); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | - public function getTtl (): int { |
|
| 110 | + public function getTtl(): int { |
|
| 111 | 111 | return $this->ttl; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string[] $keys |
| 116 | 116 | * @throws CacheException |
| 117 | 117 | */ |
| 118 | - public function remove (array $keys): void { |
|
| 118 | + public function remove(array $keys): void { |
|
| 119 | 119 | parent::remove($keys); |
| 120 | 120 | foreach ($keys as $key) { |
| 121 | 121 | $this->psr->delete("asana/{$key}"); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param int $ttl |
| 127 | 127 | * @return $this |
| 128 | 128 | */ |
| 129 | - public function setTtl (int $ttl) { |
|
| 129 | + public function setTtl(int $ttl) { |
|
| 130 | 130 | $this->ttl = $ttl; |
| 131 | 131 | return $this; |
| 132 | 132 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return string |
| 65 | 65 | */ |
| 66 | - final public function __toString (): string { |
|
| 66 | + final public function __toString(): string { |
|
| 67 | 67 | return "portfolios/{$this->getGid()}"; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - final protected function _getDir (): string { |
|
| 75 | + final protected function _getDir(): string { |
|
| 76 | 76 | return 'portfolios'; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param Project $item |
| 82 | 82 | * @return $this |
| 83 | 83 | */ |
| 84 | - public function addItem (Project $item) { |
|
| 84 | + public function addItem(Project $item) { |
|
| 85 | 85 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
| 86 | 86 | return $this; |
| 87 | 87 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param User $user |
| 91 | 91 | * @return $this |
| 92 | 92 | */ |
| 93 | - public function addMember (User $user) { |
|
| 93 | + public function addMember(User $user) { |
|
| 94 | 94 | return $this->addMembers([$user]); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param User[] $users |
| 99 | 99 | * @return $this |
| 100 | 100 | */ |
| 101 | - public function addMembers (array $users) { |
|
| 101 | + public function addMembers(array $users) { |
|
| 102 | 102 | return $this->_addWithPost("{$this}/addMembers", [ |
| 103 | 103 | 'members' => array_column($users, 'gid') |
| 104 | 104 | ], 'members', $users); |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | * @depends after-create |
| 109 | 109 | * @return Project[] |
| 110 | 110 | */ |
| 111 | - public function getItems () { |
|
| 111 | + public function getItems() { |
|
| 112 | 112 | return iterator_to_array($this); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return Traversable|Project[] |
| 117 | 117 | */ |
| 118 | - public function getIterator () { |
|
| 118 | + public function getIterator() { |
|
| 119 | 119 | return $this->api->loadEach($this, Project::class, "{$this}/items"); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param Project $item |
| 125 | 125 | * @return $this |
| 126 | 126 | */ |
| 127 | - public function removeItem (Project $item) { |
|
| 127 | + public function removeItem(Project $item) { |
|
| 128 | 128 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
| 129 | 129 | return $this; |
| 130 | 130 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param User $user |
| 134 | 134 | * @return $this |
| 135 | 135 | */ |
| 136 | - public function removeMember (User $user) { |
|
| 136 | + public function removeMember(User $user) { |
|
| 137 | 137 | return $this->removeMembers([$user]); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param User[] $users |
| 142 | 142 | * @return $this |
| 143 | 143 | */ |
| 144 | - public function removeMembers (array $users) { |
|
| 144 | + public function removeMembers(array $users) { |
|
| 145 | 145 | return $this->_removeWithPost("{$this}/removeMembers", [ |
| 146 | 146 | 'members' => array_column($users, 'gid') |
| 147 | 147 | ], 'members', $users); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param callable $filter `fn( Project $project ): bool` |
| 152 | 152 | * @return Project[] |
| 153 | 153 | */ |
| 154 | - public function selectItems (callable $filter) { |
|
| 154 | + public function selectItems(callable $filter) { |
|
| 155 | 155 | return $this->_select($this, $filter); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | \ No newline at end of file |
@@ -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 |
@@ -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]); |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - abstract public function __toString (): string; |
|
| 33 | + abstract public function __toString(): string; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @param self $entity |
| 37 | 37 | * @return bool |
| 38 | 38 | * @internal pool |
| 39 | 39 | */ |
| 40 | - final public function __merge (self $entity): bool { |
|
| 40 | + final public function __merge(self $entity): bool { |
|
| 41 | 41 | $old = $this->toArray(); |
| 42 | 42 | $this->data = array_merge($this->data, array_diff_key($entity->data, $this->diff)); |
| 43 | 43 | return $this->toArray() !== $old; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $field |
| 50 | 50 | * @return mixed |
| 51 | 51 | */ |
| 52 | - protected function _get (string $field) { |
|
| 52 | + protected function _get(string $field) { |
|
| 53 | 53 | if (!array_key_exists($field, $this->data) and $this->hasGid()) { |
| 54 | 54 | $this->_reload($field); |
| 55 | 55 | } |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | /** |
| 60 | 60 | * @param string $field |
| 61 | 61 | */ |
| 62 | - protected function _reload (string $field): void { |
|
| 62 | + protected function _reload(string $field): void { |
|
| 63 | 63 | $remote = $this->api->get($this, [], ['fields' => static::OPT_FIELDS[$field] ?? $field]); |
| 64 | 64 | $this->_setField($field, $remote[$field] ?? null); |
| 65 | 65 | $this->api->getPool()->add($this); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - protected function _setData (array $data): void { |
|
| 68 | + protected function _setData(array $data): void { |
|
| 69 | 69 | // meaningless once the entity is being created. it's constant. |
| 70 | 70 | unset($data['resource_type'], $data['type']); |
| 71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @return null|string |
| 77 | 77 | */ |
| 78 | - final public function getGid (): ?string { |
|
| 78 | + final public function getGid(): ?string { |
|
| 79 | 79 | return $this->data['gid'] ?? null; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return string[] |
| 86 | 86 | */ |
| 87 | - public function getPoolKeys () { |
|
| 87 | + public function getPoolKeys() { |
|
| 88 | 88 | return [$this->getGid(), (string)$this]; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | - final public function getResourceType (): string { |
|
| 96 | + final public function getResourceType(): string { |
|
| 97 | 97 | return static::TYPE; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @return bool |
| 102 | 102 | */ |
| 103 | - final public function hasGid (): bool { |
|
| 103 | + final public function hasGid(): bool { |
|
| 104 | 104 | return isset($this->data['gid']); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @depends after-create |
| 111 | 111 | * @return $this |
| 112 | 112 | */ |
| 113 | - public function reload () { |
|
| 113 | + public function reload() { |
|
| 114 | 114 | $remote = $this->api->get($this, [], ['expand' => 'this']); |
| 115 | 115 | if (!isset($remote['gid'])) { // null and dir guard |
| 116 | 116 | $this->api->getPool()->remove($this->getPoolKeys()); |
@@ -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 "workspaces/{$this->getGid()}"; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return OrganizationExport |
| 51 | 51 | */ |
| 52 | - public function export () { |
|
| 52 | + public function export() { |
|
| 53 | 53 | /** @var OrganizationExport $export */ |
| 54 | 54 | $export = $this->api->factory($this, OrganizationExport::class); |
| 55 | 55 | return $export->create($this); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param int $limit 1-100 |
| 70 | 70 | * @return array|AbstractEntity[] |
| 71 | 71 | */ |
| 72 | - protected function find (string $class, string $text, int $limit = 20) { |
|
| 72 | + protected function find(string $class, string $text, int $limit = 20) { |
|
| 73 | 73 | return $this->api->loadAll($this, $class, "{$this}/typeahead", [ |
| 74 | 74 | 'resource_type' => $class::TYPE, |
| 75 | 75 | 'query' => $text, |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param int $limit 1-100 |
| 85 | 85 | * @return CustomField[] |
| 86 | 86 | */ |
| 87 | - public function findCustomFields (string $text, int $limit = 20) { |
|
| 87 | + public function findCustomFields(string $text, int $limit = 20) { |
|
| 88 | 88 | return $this->find(CustomField::class, $text, $limit); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param int $limit 1-100 |
| 96 | 96 | * @return Portfolio[] |
| 97 | 97 | */ |
| 98 | - public function findPortfolios (string $text, int $limit = 20) { |
|
| 98 | + public function findPortfolios(string $text, int $limit = 20) { |
|
| 99 | 99 | return $this->find(Portfolio::class, $text, $limit); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param int $limit 1-100 |
| 107 | 107 | * @return Project[] |
| 108 | 108 | */ |
| 109 | - public function findProjects (string $text, int $limit = 20) { |
|
| 109 | + public function findProjects(string $text, int $limit = 20) { |
|
| 110 | 110 | return $this->find(Project::class, $text, $limit); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param int $limit 1-100 |
| 118 | 118 | * @return Tag[] |
| 119 | 119 | */ |
| 120 | - public function findTags (string $text, int $limit = 20) { |
|
| 120 | + public function findTags(string $text, int $limit = 20) { |
|
| 121 | 121 | return $this->find(Tag::class, $text, $limit); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | * @param int $limit 1-100 |
| 129 | 129 | * @return Task[] |
| 130 | 130 | */ |
| 131 | - public function findTasks (string $text, int $limit = 20) { |
|
| 131 | + public function findTasks(string $text, int $limit = 20) { |
|
| 132 | 132 | return $this->find(Task::class, $text, $limit); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * @return CustomField[] |
| 137 | 137 | */ |
| 138 | - public function getCustomFields () { |
|
| 138 | + public function getCustomFields() { |
|
| 139 | 139 | return $this->api->loadAll($this, CustomField::class, "{$this}/custom_fields"); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return Portfolio[] |
| 146 | 146 | */ |
| 147 | - public function getPortfolios () { |
|
| 147 | + public function getPortfolios() { |
|
| 148 | 148 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
| 149 | 149 | 'workspace' => $this->getGid(), |
| 150 | 150 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param array $filter |
| 158 | 158 | * @return Project[] |
| 159 | 159 | */ |
| 160 | - public function getProjects (array $filter = Project::GET_ACTIVE) { |
|
| 160 | + public function getProjects(array $filter = Project::GET_ACTIVE) { |
|
| 161 | 161 | $filter['workspace'] = $this->getGid(); |
| 162 | 162 | return $this->api->loadAll($this, Project::class, 'projects', $filter); |
| 163 | 163 | } |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * @return Tag[] |
| 167 | 167 | */ |
| 168 | - public function getTags () { |
|
| 168 | + public function getTags() { |
|
| 169 | 169 | return $this->api->loadAll($this, Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * @return Team[] |
| 174 | 174 | */ |
| 175 | - public function getTeams () { |
|
| 175 | + public function getTeams() { |
|
| 176 | 176 | return $this->api->loadAll($this, Team::class, "organizations/{$this->getGid()}/teams"); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $email |
| 181 | 181 | * @return null|User |
| 182 | 182 | */ |
| 183 | - public function getUserByEmail (string $email) { |
|
| 183 | + public function getUserByEmail(string $email) { |
|
| 184 | 184 | return $this->api->getPool()->get("users/{$email}", $this, function() use ($email) { |
| 185 | 185 | foreach ($this->getUsers() as $user) { |
| 186 | 186 | if ($user->getEmail() === $email) { |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * @return User[] |
| 196 | 196 | */ |
| 197 | - public function getUsers () { |
|
| 197 | + public function getUsers() { |
|
| 198 | 198 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * @return ProjectWebhook[]|TaskWebhook[] |
| 203 | 203 | */ |
| 204 | - public function getWebhooks () { |
|
| 204 | + public function getWebhooks() { |
|
| 205 | 205 | /** @var array $all */ |
| 206 | 206 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 207 | 207 | return array_map(function(array $each) { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * @return bool |
| 220 | 220 | */ |
| 221 | - final public function isOrganization (): bool { |
|
| 221 | + final public function isOrganization(): bool { |
|
| 222 | 222 | return $this->_is('is_organization'); |
| 223 | 223 | } |
| 224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @return CustomField |
| 229 | 229 | */ |
| 230 | - public function newCustomField () { |
|
| 230 | + public function newCustomField() { |
|
| 231 | 231 | /** @var CustomField $field */ |
| 232 | 232 | $field = $this->api->factory($this, CustomField::class); |
| 233 | 233 | return $field->setWorkspace($this); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return Portfolio |
| 240 | 240 | */ |
| 241 | - public function newPortfolio () { |
|
| 241 | + public function newPortfolio() { |
|
| 242 | 242 | /** @var Portfolio $portfolio */ |
| 243 | 243 | $portfolio = $this->api->factory($this, Portfolio::class); |
| 244 | 244 | return $portfolio->setWorkspace($this); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @return Project |
| 251 | 251 | */ |
| 252 | - public function newProject () { |
|
| 252 | + public function newProject() { |
|
| 253 | 253 | /** @var Project $project */ |
| 254 | 254 | $project = $this->api->factory($this, Project::class); |
| 255 | 255 | return $project->setWorkspace($this); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @return Tag |
| 262 | 262 | */ |
| 263 | - public function newTag () { |
|
| 263 | + public function newTag() { |
|
| 264 | 264 | /** @var Tag $tag */ |
| 265 | 265 | $tag = $this->api->factory($this, Tag::class); |
| 266 | 266 | return $tag->setWorkspace($this); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return Task |
| 273 | 273 | */ |
| 274 | - public function newTask () { |
|
| 274 | + public function newTask() { |
|
| 275 | 275 | /** @var Task $task */ |
| 276 | 276 | $task = $this->api->factory($this, Task::class); |
| 277 | 277 | return $task->setWorkspace($this); |