@@ -33,7 +33,7 @@ discard block  | 
                                                    ||
| 33 | 33 | 'new_task' => Task::class  | 
                                                        
| 34 | 34 | ];  | 
                                                        
| 35 | 35 | |
| 36 | -    final public function __toString (): string { | 
                                                        |
| 36 | +    final public function __toString(): string { | 
                                                        |
| 37 | 37 |          return "jobs/{$this->getGid()}"; | 
                                                        
| 38 | 38 | }  | 
                                                        
| 39 | 39 | |
@@ -42,7 +42,7 @@ discard block  | 
                                                    ||
| 42 | 42 | *  | 
                                                        
| 43 | 43 | * @return bool  | 
                                                        
| 44 | 44 | */  | 
                                                        
| 45 | -    public function isActive (): bool { | 
                                                        |
| 45 | +    public function isActive(): bool { | 
                                                        |
| 46 | 46 | return $this->getStatus() === self::STATUS_ACTIVE;  | 
                                                        
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block  | 
                                                    ||
| 51 | 51 | *  | 
                                                        
| 52 | 52 | * @return bool  | 
                                                        
| 53 | 53 | */  | 
                                                        
| 54 | -    public function isDone (): bool { | 
                                                        |
| 54 | +    public function isDone(): bool { | 
                                                        |
| 55 | 55 | return $this->isSuccessful() or $this->isFailed();  | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | *  | 
                                                        
| 61 | 61 | * @return bool  | 
                                                        
| 62 | 62 | */  | 
                                                        
| 63 | -    public function isFailed (): bool { | 
                                                        |
| 63 | +    public function isFailed(): bool { | 
                                                        |
| 64 | 64 | return $this->getStatus() === self::STATUS_FAIL;  | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
@@ -69,7 +69,7 @@ discard block  | 
                                                    ||
| 69 | 69 | *  | 
                                                        
| 70 | 70 | * @return bool  | 
                                                        
| 71 | 71 | */  | 
                                                        
| 72 | -    public function isQueued (): bool { | 
                                                        |
| 72 | +    public function isQueued(): bool { | 
                                                        |
| 73 | 73 | return $this->getStatus() === self::STATUS_QUEUED;  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
@@ -78,7 +78,7 @@ discard block  | 
                                                    ||
| 78 | 78 | *  | 
                                                        
| 79 | 79 | * @return bool  | 
                                                        
| 80 | 80 | */  | 
                                                        
| 81 | -    public function isSuccessful (): bool { | 
                                                        |
| 81 | +    public function isSuccessful(): bool { | 
                                                        |
| 82 | 82 | return $this->getStatus() === self::STATUS_SUCCESS;  | 
                                                        
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
@@ -87,7 +87,7 @@ discard block  | 
                                                    ||
| 87 | 87 | *  | 
                                                        
| 88 | 88 | * @return $this  | 
                                                        
| 89 | 89 | */  | 
                                                        
| 90 | -    public function wait () { | 
                                                        |
| 90 | +    public function wait() { | 
                                                        |
| 91 | 91 |          while (!$this->isDone()) { | 
                                                        
| 92 | 92 | sleep(3);  | 
                                                        
| 93 | 93 | $this->reload();  | 
                                                        
@@ -30,14 +30,14 @@ discard block  | 
                                                    ||
| 30 | 30 | 'workspace' => Workspace::class  | 
                                                        
| 31 | 31 | ];  | 
                                                        
| 32 | 32 | |
| 33 | -    final public function __toString (): string { | 
                                                        |
| 33 | +    final public function __toString(): string { | 
                                                        |
| 34 | 34 |          return "user_task_lists/{$this->getGid()}"; | 
                                                        
| 35 | 35 | }  | 
                                                        
| 36 | 36 | |
| 37 | 37 | /**  | 
                                                        
| 38 | 38 | * @return Task[]  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | -    public function getIncompleteTasks () { | 
                                                        |
| 40 | +    public function getIncompleteTasks() { | 
                                                        |
| 41 | 41 |          return $this->loadAll(Task::class, "{$this}/tasks", ['completed_since' => 'now']); | 
                                                        
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
@@ -46,14 +46,14 @@ discard block  | 
                                                    ||
| 46 | 46 | *  | 
                                                        
| 47 | 47 | * @return ArrayIterator|Task[]  | 
                                                        
| 48 | 48 | */  | 
                                                        
| 49 | -    public function getIterator () { | 
                                                        |
| 49 | +    public function getIterator() { | 
                                                        |
| 50 | 50 | return new ArrayIterator($this->getTasks());  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | |
| 53 | 53 | /**  | 
                                                        
| 54 | 54 | * @return Task[]  | 
                                                        
| 55 | 55 | */  | 
                                                        
| 56 | -    public function getTasks () { | 
                                                        |
| 56 | +    public function getTasks() { | 
                                                        |
| 57 | 57 |          return $this->loadAll(Task::class, "{$this}/tasks"); | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | \ No newline at end of file  | 
                                                        
@@ -31,18 +31,18 @@  | 
                                                    ||
| 31 | 31 | 'workspace' => Workspace::class  | 
                                                        
| 32 | 32 | ];  | 
                                                        
| 33 | 33 | |
| 34 | -    final public function __toString (): string { | 
                                                        |
| 34 | +    final public function __toString(): string { | 
                                                        |
| 35 | 35 |          return "tags/{$this->getGid()}"; | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | |
| 38 | -    final protected function _getDir (): string { | 
                                                        |
| 38 | +    final protected function _getDir(): string { | 
                                                        |
| 39 | 39 | return 'tags';  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 | |
| 42 | 42 | /**  | 
                                                        
| 43 | 43 | * @return Task[]  | 
                                                        
| 44 | 44 | */  | 
                                                        
| 45 | -    public function getTasks () { | 
                                                        |
| 45 | +    public function getTasks() { | 
                                                        |
| 46 | 46 |          return $this->loadAll(Task::class, "{$this}/tasks"); | 
                                                        
| 47 | 47 | }  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | \ No newline at end of file  | 
                                                        
@@ -40,11 +40,11 @@ discard block  | 
                                                    ||
| 40 | 40 | 'enum_options' => [EnumOption::class],  | 
                                                        
| 41 | 41 | ];  | 
                                                        
| 42 | 42 | |
| 43 | -    final public function __toString (): string { | 
                                                        |
| 43 | +    final public function __toString(): string { | 
                                                        |
| 44 | 44 |          return "custom_fields/{$this->getGid()}"; | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | |
| 47 | -    final protected function _getDir (): string { | 
                                                        |
| 47 | +    final protected function _getDir(): string { | 
                                                        |
| 48 | 48 | return 'custom_fields';  | 
                                                        
| 49 | 49 | }  | 
                                                        
| 50 | 50 | |
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | * @param string $name  | 
                                                        
| 53 | 53 | * @return EnumOption  | 
                                                        
| 54 | 54 | */  | 
                                                        
| 55 | -    public function addEnumOption (string $name) { | 
                                                        |
| 55 | +    public function addEnumOption(string $name) { | 
                                                        |
| 56 | 56 | /** @var EnumOption $option */  | 
                                                        
| 57 | 57 | $option = $this->factory(EnumOption::class);  | 
                                                        
| 58 | 58 | $option->setName($name);  | 
                                                        
@@ -69,28 +69,28 @@ discard block  | 
                                                    ||
| 69 | 69 | /**  | 
                                                        
| 70 | 70 | * @return bool  | 
                                                        
| 71 | 71 | */  | 
                                                        
| 72 | -    public function hasNotificationsEnabled (): bool { | 
                                                        |
| 72 | +    public function hasNotificationsEnabled(): bool { | 
                                                        |
| 73 | 73 |          return $this->_is('has_notifications_enabled'); | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
| 76 | 76 | /**  | 
                                                        
| 77 | 77 | * @return bool  | 
                                                        
| 78 | 78 | */  | 
                                                        
| 79 | -    public function isEnum (): bool { | 
                                                        |
| 79 | +    public function isEnum(): bool { | 
                                                        |
| 80 | 80 | return $this->getResourceSubtype() === self::TYPE_ENUM;  | 
                                                        
| 81 | 81 | }  | 
                                                        
| 82 | 82 | |
| 83 | 83 | /**  | 
                                                        
| 84 | 84 | * @return bool  | 
                                                        
| 85 | 85 | */  | 
                                                        
| 86 | -    public function isGlobalToWorkspace (): bool { | 
                                                        |
| 86 | +    public function isGlobalToWorkspace(): bool { | 
                                                        |
| 87 | 87 |          return $this->_is('is_global_to_workspace'); | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | 90 | /**  | 
                                                        
| 91 | 91 | * @return bool  | 
                                                        
| 92 | 92 | */  | 
                                                        
| 93 | -    final public function isText (): bool { | 
                                                        |
| 93 | +    final public function isText(): bool { | 
                                                        |
| 94 | 94 | return $this->getResourceSubtype() === self::TYPE_TEXT;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | |
@@ -98,7 +98,7 @@ discard block  | 
                                                    ||
| 98 | 98 | * @param bool $flag  | 
                                                        
| 99 | 99 | * @return $this  | 
                                                        
| 100 | 100 | */  | 
                                                        
| 101 | -    public function setGlobalToWorkspace (bool $flag) { | 
                                                        |
| 101 | +    public function setGlobalToWorkspace(bool $flag) { | 
                                                        |
| 102 | 102 |          return $this->_set('is_global_to_workspace', $flag); | 
                                                        
| 103 | 103 | }  | 
                                                        
| 104 | 104 | |
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | * @param bool $flag  | 
                                                        
| 107 | 107 | * @return $this  | 
                                                        
| 108 | 108 | */  | 
                                                        
| 109 | -    public function setNotificationsEnabled (bool $flag) { | 
                                                        |
| 109 | +    public function setNotificationsEnabled(bool $flag) { | 
                                                        |
| 110 | 110 |          return $this->_set('has_notifications_enabled', $flag); | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | |
@@ -52,23 +52,23 @@  | 
                                                    ||
| 52 | 52 | * @param Project $project  | 
                                                        
| 53 | 53 | * @param array $data  | 
                                                        
| 54 | 54 | */  | 
                                                        
| 55 | -    public function __construct (Project $project, array $data = []) { | 
                                                        |
| 55 | +    public function __construct(Project $project, array $data = []) { | 
                                                        |
| 56 | 56 | parent::__construct($project, $data);  | 
                                                        
| 57 | 57 | $this->project = $project;  | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | -    final public function __toString (): string { | 
                                                        |
| 60 | +    final public function __toString(): string { | 
                                                        |
| 61 | 61 |          return "project_statuses/{$this->getGid()}"; | 
                                                        
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | -    final protected function _getDir (): string { | 
                                                        |
| 64 | +    final protected function _getDir(): string { | 
                                                        |
| 65 | 65 |          return "{$this->project}/project_statuses"; | 
                                                        
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |
| 68 | 68 | /**  | 
                                                        
| 69 | 69 | * @return Project  | 
                                                        
| 70 | 70 | */  | 
                                                        
| 71 | -    public function getProject () { | 
                                                        |
| 71 | +    public function getProject() { | 
                                                        |
| 72 | 72 | return $this->project;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | \ No newline at end of file  | 
                                                        
@@ -28,18 +28,18 @@ discard block  | 
                                                    ||
| 28 | 28 | 'project' => Project::class  | 
                                                        
| 29 | 29 | ];  | 
                                                        
| 30 | 30 | |
| 31 | -    final public function __toString (): string { | 
                                                        |
| 31 | +    final public function __toString(): string { | 
                                                        |
| 32 | 32 |          return "sections/{$this->getGid()}"; | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | 34 | |
| 35 | -    final protected function _getDir (): string { | 
                                                        |
| 35 | +    final protected function _getDir(): string { | 
                                                        |
| 36 | 36 |          return "{$this->getProject()}/sections"; | 
                                                        
| 37 | 37 | }  | 
                                                        
| 38 | 38 | |
| 39 | 39 | /**  | 
                                                        
| 40 | 40 | * @return Task[]  | 
                                                        
| 41 | 41 | */  | 
                                                        
| 42 | -    public function getTasks () { | 
                                                        |
| 42 | +    public function getTasks() { | 
                                                        |
| 43 | 43 | return $this->loadAll(Task::class, 'tasks', ['section' => $this->getGid()]);  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
@@ -49,7 +49,7 @@ discard block  | 
                                                    ||
| 49 | 49 | * @depends after-create  | 
                                                        
| 50 | 50 | * @return Task  | 
                                                        
| 51 | 51 | */  | 
                                                        
| 52 | -    public function newTask () { | 
                                                        |
| 52 | +    public function newTask() { | 
                                                        |
| 53 | 53 | /** @var Task $task */  | 
                                                        
| 54 | 54 | $task = $this->factory(Task::class);  | 
                                                        
| 55 | 55 | return $task->addToProject($this);  | 
                                                        
@@ -39,11 +39,11 @@ discard block  | 
                                                    ||
| 39 | 39 | 'workspace' => Workspace::class  | 
                                                        
| 40 | 40 | ];  | 
                                                        
| 41 | 41 | |
| 42 | -    final public function __toString (): string { | 
                                                        |
| 42 | +    final public function __toString(): string { | 
                                                        |
| 43 | 43 |          return "portfolios/{$this->getGid()}"; | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | -    final protected function _getDir (): string { | 
                                                        |
| 46 | +    final protected function _getDir(): string { | 
                                                        |
| 47 | 47 | return 'portfolios';  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | * @param Project $item  | 
                                                        
| 53 | 53 | * @return $this  | 
                                                        
| 54 | 54 | */  | 
                                                        
| 55 | -    public function addItem (Project $item) { | 
                                                        |
| 55 | +    public function addItem(Project $item) { | 
                                                        |
| 56 | 56 |          $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); | 
                                                        
| 57 | 57 | return $this;  | 
                                                        
| 58 | 58 | }  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | * @param User $user  | 
                                                        
| 62 | 62 | * @return $this  | 
                                                        
| 63 | 63 | */  | 
                                                        
| 64 | -    public function addMember (User $user) { | 
                                                        |
| 64 | +    public function addMember(User $user) { | 
                                                        |
| 65 | 65 | return $this->addMembers([$user]);  | 
                                                        
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |
@@ -69,7 +69,7 @@ discard block  | 
                                                    ||
| 69 | 69 | * @param User[] $users  | 
                                                        
| 70 | 70 | * @return $this  | 
                                                        
| 71 | 71 | */  | 
                                                        
| 72 | -    public function addMembers (array $users) { | 
                                                        |
| 72 | +    public function addMembers(array $users) { | 
                                                        |
| 73 | 73 |          if ($this->hasGid()) { | 
                                                        
| 74 | 74 |              $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]); | 
                                                        
| 75 | 75 |              $this->_merge('members', $users); | 
                                                        
@@ -84,7 +84,7 @@ discard block  | 
                                                    ||
| 84 | 84 | * @depends after-create  | 
                                                        
| 85 | 85 | * @return Project[]  | 
                                                        
| 86 | 86 | */  | 
                                                        
| 87 | -    public function getItems () { | 
                                                        |
| 87 | +    public function getItems() { | 
                                                        |
| 88 | 88 |          return $this->loadAll(Project::class, "{$this}/items"); | 
                                                        
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
@@ -93,7 +93,7 @@ discard block  | 
                                                    ||
| 93 | 93 | * @param Project $item  | 
                                                        
| 94 | 94 | * @return $this  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | -    public function removeItem (Project $item) { | 
                                                        |
| 96 | +    public function removeItem(Project $item) { | 
                                                        |
| 97 | 97 |          $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); | 
                                                        
| 98 | 98 | return $this;  | 
                                                        
| 99 | 99 | }  | 
                                                        
@@ -102,7 +102,7 @@ discard block  | 
                                                    ||
| 102 | 102 | * @param User $user  | 
                                                        
| 103 | 103 | * @return $this  | 
                                                        
| 104 | 104 | */  | 
                                                        
| 105 | -    public function removeMember (User $user) { | 
                                                        |
| 105 | +    public function removeMember(User $user) { | 
                                                        |
| 106 | 106 | return $this->removeMembers([$user]);  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
@@ -110,7 +110,7 @@ discard block  | 
                                                    ||
| 110 | 110 | * @param User[] $users  | 
                                                        
| 111 | 111 | * @return $this  | 
                                                        
| 112 | 112 | */  | 
                                                        
| 113 | -    public function removeMembers (array $users) { | 
                                                        |
| 113 | +    public function removeMembers(array $users) { | 
                                                        |
| 114 | 114 |          if ($this->hasGid()) { | 
                                                        
| 115 | 115 |              $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]); | 
                                                        
| 116 | 116 | }  | 
                                                        
@@ -40,7 +40,7 @@ discard block  | 
                                                    ||
| 40 | 40 | * @param Api|Data $caller  | 
                                                        
| 41 | 41 | * @param array $data  | 
                                                        
| 42 | 42 | */  | 
                                                        
| 43 | -    public function __construct ($caller, array $data = []) { | 
                                                        |
| 43 | +    public function __construct($caller, array $data = []) { | 
                                                        |
| 44 | 44 | $this->api = $caller instanceof self ? $caller->api : $caller;  | 
                                                        
| 45 | 45 | $this->_setData($data);  | 
                                                        
| 46 | 46 | }  | 
                                                        
@@ -56,9 +56,9 @@ discard block  | 
                                                    ||
| 56 | 56 | * @param array $args  | 
                                                        
| 57 | 57 | * @return mixed  | 
                                                        
| 58 | 58 | */  | 
                                                        
| 59 | -    public function __call (string $method, array $args) { | 
                                                        |
| 59 | +    public function __call(string $method, array $args) { | 
                                                        |
| 60 | 60 | static $cache = [];  | 
                                                        
| 61 | -        if (!$call =& $cache[$method]) { | 
                                                        |
| 61 | +        if (!$call = & $cache[$method]) { | 
                                                        |
| 62 | 62 |              preg_match('/^(get|has|is|set)(.+)$/', $method, $call); | 
                                                        
| 63 | 63 | $call[1] = '_' . $call[1];  | 
                                                        
| 64 | 64 |              $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { | 
                                                        
@@ -68,7 +68,7 @@ discard block  | 
                                                    ||
| 68 | 68 |          return $this->{$call[1]}($call[2], ...$args); | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | -    public function __debugInfo (): array { | 
                                                        |
| 71 | +    public function __debugInfo(): array { | 
                                                        |
| 72 | 72 | return $this->data;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
@@ -78,7 +78,7 @@ discard block  | 
                                                    ||
| 78 | 78 | * @param $key  | 
                                                        
| 79 | 79 | * @return null|Data|mixed  | 
                                                        
| 80 | 80 | */  | 
                                                        
| 81 | -    final public function __get ($key) { | 
                                                        |
| 81 | +    final public function __get($key) { | 
                                                        |
| 82 | 82 | return $this->_get($key);  | 
                                                        
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | * @param $key  | 
                                                        
| 91 | 91 | * @return bool  | 
                                                        
| 92 | 92 | */  | 
                                                        
| 93 | -    final public function __isset ($key) { | 
                                                        |
| 93 | +    final public function __isset($key) { | 
                                                        |
| 94 | 94 | return true;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | |
@@ -102,7 +102,7 @@ discard block  | 
                                                    ||
| 102 | 102 | * @param string $key  | 
                                                        
| 103 | 103 | * @return mixed  | 
                                                        
| 104 | 104 | */  | 
                                                        
| 105 | -    protected function _get (string $key) { | 
                                                        |
| 105 | +    protected function _get(string $key) { | 
                                                        |
| 106 | 106 | return $this->data[$key] ?? null;  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
@@ -116,7 +116,7 @@ discard block  | 
                                                    ||
| 116 | 116 | * @param string $key  | 
                                                        
| 117 | 117 | * @return bool  | 
                                                        
| 118 | 118 | */  | 
                                                        
| 119 | -    protected function _has (string $key): bool { | 
                                                        |
| 119 | +    protected function _has(string $key): bool { | 
                                                        |
| 120 | 120 | $value = $this->_get($key);  | 
                                                        
| 121 | 121 |          if (isset($value)) { | 
                                                        
| 122 | 122 |              if (is_countable($value)) { | 
                                                        
@@ -139,7 +139,7 @@ discard block  | 
                                                    ||
| 139 | 139 | * @param string $key  | 
                                                        
| 140 | 140 | * @return bool  | 
                                                        
| 141 | 141 | */  | 
                                                        
| 142 | -    protected function _is (string $key): bool { | 
                                                        |
| 142 | +    protected function _is(string $key): bool { | 
                                                        |
| 143 | 143 | return !empty($this->_get($key));  | 
                                                        
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
@@ -152,7 +152,7 @@ discard block  | 
                                                    ||
| 152 | 152 | * @param mixed $value  | 
                                                        
| 153 | 153 | * @return $this  | 
                                                        
| 154 | 154 | */  | 
                                                        
| 155 | -    protected function _set (string $key, $value) { | 
                                                        |
| 155 | +    protected function _set(string $key, $value) { | 
                                                        |
| 156 | 156 | $this->data[$key] = $value;  | 
                                                        
| 157 | 157 | $this->diff[$key] = true;  | 
                                                        
| 158 | 158 | return $this;  | 
                                                        
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 | *  | 
                                                        
| 164 | 164 | * @param array $data  | 
                                                        
| 165 | 165 | */  | 
                                                        
| 166 | -    protected function _setData (array $data): void { | 
                                                        |
| 166 | +    protected function _setData(array $data): void { | 
                                                        |
| 167 | 167 | $this->data = $this->diff = [];  | 
                                                        
| 168 | 168 |          foreach ($data as $key => $value) { | 
                                                        
| 169 | 169 | $this->_setMapped($key, $value);  | 
                                                        
@@ -176,7 +176,7 @@ discard block  | 
                                                    ||
| 176 | 176 | * @param string $key  | 
                                                        
| 177 | 177 | * @param null|Data|array $value  | 
                                                        
| 178 | 178 | */  | 
                                                        
| 179 | -    protected function _setMapped (string $key, $value): void { | 
                                                        |
| 179 | +    protected function _setMapped(string $key, $value): void { | 
                                                        |
| 180 | 180 | unset($this->diff[$key]);  | 
                                                        
| 181 | 181 | |
| 182 | 182 | // use unmapped values, null, [], Data, and Data[] as-is  | 
                                                        
@@ -216,7 +216,7 @@ discard block  | 
                                                    ||
| 216 | 216 | * @param array $data  | 
                                                        
| 217 | 217 | * @return mixed  | 
                                                        
| 218 | 218 | */  | 
                                                        
| 219 | -    final protected function factory (string $class, array $data = []) { | 
                                                        |
| 219 | +    final protected function factory(string $class, array $data = []) { | 
                                                        |
| 220 | 220 | return $this->api->factory($class, $this, $data);  | 
                                                        
| 221 | 221 | }  | 
                                                        
| 222 | 222 | |
@@ -225,7 +225,7 @@ discard block  | 
                                                    ||
| 225 | 225 | *  | 
                                                        
| 226 | 226 | * @return array  | 
                                                        
| 227 | 227 | */  | 
                                                        
| 228 | -    public function getDiff (): array { | 
                                                        |
| 228 | +    public function getDiff(): array { | 
                                                        |
| 229 | 229 |          $convert = function($each) use (&$convert) { | 
                                                        
| 230 | 230 | // convert existing entities to gids  | 
                                                        
| 231 | 231 |              if ($each instanceof AbstractEntity and $each->hasGid()) { | 
                                                        
@@ -250,7 +250,7 @@ discard block  | 
                                                    ||
| 250 | 250 | *  | 
                                                        
| 251 | 251 | * @return bool  | 
                                                        
| 252 | 252 | */  | 
                                                        
| 253 | -    final public function isDiff (): bool { | 
                                                        |
| 253 | +    final public function isDiff(): bool { | 
                                                        |
| 254 | 254 | return (bool)$this->diff;  | 
                                                        
| 255 | 255 | }  | 
                                                        
| 256 | 256 | |
@@ -258,7 +258,7 @@ discard block  | 
                                                    ||
| 258 | 258 | * @see toArray()  | 
                                                        
| 259 | 259 | * @return array  | 
                                                        
| 260 | 260 | */  | 
                                                        
| 261 | -    public function jsonSerialize (): array { | 
                                                        |
| 261 | +    public function jsonSerialize(): array { | 
                                                        |
| 262 | 262 | return $this->toArray();  | 
                                                        
| 263 | 263 | }  | 
                                                        
| 264 | 264 | |
@@ -272,7 +272,7 @@ discard block  | 
                                                    ||
| 272 | 272 | * @param array $query  | 
                                                        
| 273 | 273 | * @return null|mixed|AbstractEntity  | 
                                                        
| 274 | 274 | */  | 
                                                        
| 275 | -    final protected function load (string $class, string $path, array $query = []) { | 
                                                        |
| 275 | +    final protected function load(string $class, string $path, array $query = []) { | 
                                                        |
| 276 | 276 | return $this->api->load($class, $this, $path, $query);  | 
                                                        
| 277 | 277 | }  | 
                                                        
| 278 | 278 | |
@@ -287,7 +287,7 @@ discard block  | 
                                                    ||
| 287 | 287 | * @param int $pages  | 
                                                        
| 288 | 288 | * @return array|AbstractEntity[]  | 
                                                        
| 289 | 289 | */  | 
                                                        
| 290 | -    final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { | 
                                                        |
| 290 | +    final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { | 
                                                        |
| 291 | 291 | return $this->api->loadAll($class, $this, $path, $query, $pages);  | 
                                                        
| 292 | 292 | }  | 
                                                        
| 293 | 293 | |
@@ -296,7 +296,7 @@ discard block  | 
                                                    ||
| 296 | 296 | *  | 
                                                        
| 297 | 297 | * @return string  | 
                                                        
| 298 | 298 | */  | 
                                                        
| 299 | -    public function serialize (): string { | 
                                                        |
| 299 | +    public function serialize(): string { | 
                                                        |
| 300 | 300 | return serialize($this->toArray());  | 
                                                        
| 301 | 301 | }  | 
                                                        
| 302 | 302 | |
@@ -305,7 +305,7 @@ discard block  | 
                                                    ||
| 305 | 305 | *  | 
                                                        
| 306 | 306 | * @return array  | 
                                                        
| 307 | 307 | */  | 
                                                        
| 308 | -    public function toArray (): array { | 
                                                        |
| 308 | +    public function toArray(): array { | 
                                                        |
| 309 | 309 |          if (!$this->api) { | 
                                                        
| 310 | 310 | return $this->data;  | 
                                                        
| 311 | 311 | }  | 
                                                        
@@ -329,7 +329,7 @@ discard block  | 
                                                    ||
| 329 | 329 | *  | 
                                                        
| 330 | 330 | * @param $serialized  | 
                                                        
| 331 | 331 | */  | 
                                                        
| 332 | -    public function unserialize ($serialized): void { | 
                                                        |
| 332 | +    public function unserialize($serialized): void { | 
                                                        |
| 333 | 333 | $this->api = Api::getDefault();  | 
                                                        
| 334 | 334 | $this->data = unserialize($serialized);  | 
                                                        
| 335 | 335 | }  | 
                                                        
@@ -16,7 +16,7 @@ discard block  | 
                                                    ||
| 16 | 16 | *  | 
                                                        
| 17 | 17 | * @return string  | 
                                                        
| 18 | 18 | */  | 
                                                        
| 19 | - abstract public function __toString (): string;  | 
                                                        |
| 19 | + abstract public function __toString(): string;  | 
                                                        |
| 20 | 20 | |
| 21 | 21 | /**  | 
                                                        
| 22 | 22 | * Maps lazy-loaded / reloadable fields to their proper expanded field expression.  | 
                                                        
@@ -33,7 +33,7 @@ discard block  | 
                                                    ||
| 33 | 33 | * @param AbstractEntity[] $entities  | 
                                                        
| 34 | 34 | * @return string[]  | 
                                                        
| 35 | 35 | */  | 
                                                        
| 36 | -    protected static function _getGids (array $entities) { | 
                                                        |
| 36 | +    protected static function _getGids(array $entities) { | 
                                                        |
| 37 | 37 |          return array_map(function(AbstractEntity $entity) { | 
                                                        
| 38 | 38 | return $entity->getGid();  | 
                                                        
| 39 | 39 | }, $entities);  | 
                                                        
@@ -45,7 +45,7 @@ discard block  | 
                                                    ||
| 45 | 45 | * @param string $key  | 
                                                        
| 46 | 46 | * @return mixed  | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | -    protected function _get (string $key) { | 
                                                        |
| 48 | +    protected function _get(string $key) { | 
                                                        |
| 49 | 49 |          if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop | 
                                                        
| 50 | 50 | $this->reload($key);  | 
                                                        
| 51 | 51 | }  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | * @param bool $force  | 
                                                        
| 61 | 61 | * @return $this  | 
                                                        
| 62 | 62 | */  | 
                                                        
| 63 | -    protected function _merge (string $key, array $entities, $force = false) { | 
                                                        |
| 63 | +    protected function _merge(string $key, array $entities, $force = false) { | 
                                                        |
| 64 | 64 |          if ($force or isset($this->data[$key])) { | 
                                                        
| 65 | 65 |              foreach ($entities as $entity) { | 
                                                        
| 66 | 66 | $this->data[$key][] = $entity;  | 
                                                        
@@ -83,7 +83,7 @@ discard block  | 
                                                    ||
| 83 | 83 | * @param AbstractEntity[] $entities  | 
                                                        
| 84 | 84 | * @return $this  | 
                                                        
| 85 | 85 | */  | 
                                                        
| 86 | -    protected function _remove (string $key, array $entities) { | 
                                                        |
| 86 | +    protected function _remove(string $key, array $entities) { | 
                                                        |
| 87 | 87 |          if (isset($this->data[$key])) { | 
                                                        
| 88 | 88 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities));  | 
                                                        
| 89 | 89 | $this->api->getCache()->add($this);  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | * @param AbstractEntity $entity  | 
                                                        
| 98 | 98 | * @return $this  | 
                                                        
| 99 | 99 | */  | 
                                                        
| 100 | -    public function merge (AbstractEntity $entity) { | 
                                                        |
| 100 | +    public function merge(AbstractEntity $entity) { | 
                                                        |
| 101 | 101 | assert($entity->api); // hydrated  | 
                                                        
| 102 | 102 |          foreach ($entity->data as $key => $value) { | 
                                                        
| 103 | 103 |              if (!array_key_exists($key, $this->data) and !isset($entity->diff[$key])) { | 
                                                        
@@ -113,7 +113,7 @@ discard block  | 
                                                    ||
| 113 | 113 | * @param string $key  | 
                                                        
| 114 | 114 | * @return $this  | 
                                                        
| 115 | 115 | */  | 
                                                        
| 116 | -    public function reload (string $key = null) { | 
                                                        |
| 116 | +    public function reload(string $key = null) { | 
                                                        |
| 117 | 117 |          if (isset($key)) { | 
                                                        
| 118 | 118 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null;  | 
                                                        
| 119 | 119 | $this->_setMapped($key, $value);  | 
                                                        
@@ -68,8 +68,7 @@ discard block  | 
                                                    ||
| 68 | 68 | $this->data[$key] = array_values(array_unique($this->data[$key]));  | 
                                                        
| 69 | 69 |              if ($force) { | 
                                                        
| 70 | 70 | $this->diff[$key] = true;  | 
                                                        
| 71 | - }  | 
                                                        |
| 72 | -            else { | 
                                                        |
| 71 | +            } else { | 
                                                        |
| 73 | 72 | $this->api->getCache()->add($this);  | 
                                                        
| 74 | 73 | }  | 
                                                        
| 75 | 74 | }  | 
                                                        
@@ -117,8 +116,7 @@ discard block  | 
                                                    ||
| 117 | 116 |          if (isset($key)) { | 
                                                        
| 118 | 117 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null;  | 
                                                        
| 119 | 118 | $this->_setMapped($key, $value);  | 
                                                        
| 120 | - }  | 
                                                        |
| 121 | -        else { | 
                                                        |
| 119 | +        } else { | 
                                                        |
| 122 | 120 | $this->_setData($this->api->get($this, [], ['expand' => 'this']));  | 
                                                        
| 123 | 121 | }  | 
                                                        
| 124 | 122 | $this->api->getCache()->add($this);  |