@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - final public function __toString (): string { |
|
| 40 | + final public function __toString(): string { |
|
| 41 | 41 | return "users/{$this->getGid()}"; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param Workspace $workspace |
| 46 | 46 | * @return $this |
| 47 | 47 | */ |
| 48 | - public function addToWorkspace (Workspace $workspace) { |
|
| 48 | + public function addToWorkspace(Workspace $workspace) { |
|
| 49 | 49 | return $this->_addWithPost("{$workspace}/addUser", [ |
| 50 | 50 | 'user' => $this->getGid() |
| 51 | 51 | ], 'workspaces', [$workspace]); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return Workspace |
| 58 | 58 | */ |
| 59 | - public function getDefaultWorkspace () { |
|
| 59 | + public function getDefaultWorkspace() { |
|
| 60 | 60 | return $this->getWorkspaces()[0]; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 65 | 65 | * @return Portfolio[] |
| 66 | 66 | */ |
| 67 | - public function getFavoritePortfolios (Workspace $workspace = null) { |
|
| 67 | + public function getFavoritePortfolios(Workspace $workspace = null) { |
|
| 68 | 68 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 73 | 73 | * @return Project[] |
| 74 | 74 | */ |
| 75 | - public function getFavoriteProjects (Workspace $workspace = null) { |
|
| 75 | + public function getFavoriteProjects(Workspace $workspace = null) { |
|
| 76 | 76 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 81 | 81 | * @return Tag[] |
| 82 | 82 | */ |
| 83 | - public function getFavoriteTags (Workspace $workspace = null) { |
|
| 83 | + public function getFavoriteTags(Workspace $workspace = null) { |
|
| 84 | 84 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 89 | 89 | * @return Team[] |
| 90 | 90 | */ |
| 91 | - public function getFavoriteTeams (Workspace $workspace = null) { |
|
| 91 | + public function getFavoriteTeams(Workspace $workspace = null) { |
|
| 92 | 92 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 97 | 97 | * @return User[] |
| 98 | 98 | */ |
| 99 | - public function getFavoriteUsers (Workspace $workspace = null) { |
|
| 99 | + public function getFavoriteUsers(Workspace $workspace = null) { |
|
| 100 | 100 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 107 | 107 | * @return array |
| 108 | 108 | */ |
| 109 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) { |
|
| 109 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) { |
|
| 110 | 110 | return $this->api->loadAll($this, $class, "{$this}/favorites", [ |
| 111 | 111 | 'resource_type' => $resourceType, |
| 112 | 112 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid() |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | /** |
| 117 | 117 | * @return string[] |
| 118 | 118 | */ |
| 119 | - public function getPoolKeys () { |
|
| 119 | + public function getPoolKeys() { |
|
| 120 | 120 | $keys = parent::getPoolKeys(); |
| 121 | 121 | |
| 122 | 122 | // include email as a key if it's loaded |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param null|Workspace $workspace |
| 132 | 132 | * @return Portfolio[] |
| 133 | 133 | */ |
| 134 | - public function getPortfolios (Workspace $workspace = null) { |
|
| 134 | + public function getPortfolios(Workspace $workspace = null) { |
|
| 135 | 135 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
| 136 | 136 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid(), |
| 137 | 137 | 'owner' => $this->getGid() |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param null|Workspace $workspace Falls back to the default workspace. |
| 143 | 143 | * @return TaskList |
| 144 | 144 | */ |
| 145 | - public function getTaskList (Workspace $workspace = null) { |
|
| 145 | + public function getTaskList(Workspace $workspace = null) { |
|
| 146 | 146 | return $this->api->load($this, TaskList::class, "{$this}/user_task_list", [ |
| 147 | 147 | 'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid() |
| 148 | 148 | ]); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string[] $filter `workspace` falls back to the default. |
| 155 | 155 | * @return Task[] |
| 156 | 156 | */ |
| 157 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
| 157 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
| 158 | 158 | $filter['assignee'] = $this->getGid(); |
| 159 | 159 | $filter += ['workspace' => $this->api->getDefaultWorkspace()->getGid()]; |
| 160 | 160 | return $this->api->loadAll($this, Task::class, 'tasks', $filter); |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | * @param null|Workspace $organization Falls back to the default workspace. |
| 169 | 169 | * @return Team[] |
| 170 | 170 | */ |
| 171 | - public function getTeams (Workspace $organization = null) { |
|
| 171 | + public function getTeams(Workspace $organization = null) { |
|
| 172 | 172 | return $this->api->loadAll($this, Team::class, "{$this}/teams", [ |
| 173 | 173 | 'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid() |
| 174 | 174 | ]); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function getUrl (): string { |
|
| 177 | + public function getUrl(): string { |
|
| 178 | 178 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param Workspace $workspace |
| 183 | 183 | * @return $this |
| 184 | 184 | */ |
| 185 | - public function removeFromWorkspace (Workspace $workspace) { |
|
| 185 | + public function removeFromWorkspace(Workspace $workspace) { |
|
| 186 | 186 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
| 187 | 187 | 'user' => $this->getGid() |
| 188 | 188 | ], 'workspaces', [$workspace]); |
@@ -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 |
@@ -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))); |
@@ -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); |