@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $task; |
26 | 26 | |
27 | - public function __construct (Task $task, array $data = []) { |
|
27 | + public function __construct(Task $task, array $data = []) { |
|
28 | 28 | parent::__construct($task, $data); |
29 | 29 | $this->task = $task; |
30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param mixed $value |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - protected function _set (string $key, $value) { |
|
39 | + protected function _set(string $key, $value) { |
|
40 | 40 | $this->task->diff['external'] = true; |
41 | 41 | return parent::_set($key, $value); |
42 | 42 | } |
@@ -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 |
@@ -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); |
@@ -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); |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | 'task' => Task::class |
46 | 46 | ]; |
47 | 47 | |
48 | - final public function __toString (): string { |
|
48 | + final public function __toString(): string { |
|
49 | 49 | return "stories/{$this->getGid()}"; |
50 | 50 | } |
51 | 51 | |
52 | - final protected function _getDir (): string { |
|
52 | + final protected function _getDir(): string { |
|
53 | 53 | return "{$this->getTask()}/stories"; |
54 | 54 | } |
55 | 55 | |
56 | - final public function isComment (): bool { |
|
56 | + final public function isComment(): bool { |
|
57 | 57 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
58 | 58 | } |
59 | 59 | |
60 | - public function isEdited (): bool { |
|
60 | + public function isEdited(): bool { |
|
61 | 61 | return $this->_is('is_edited'); |
62 | 62 | } |
63 | 63 | |
64 | - public function isPinned (): bool { |
|
64 | + public function isPinned(): bool { |
|
65 | 65 | return $this->_is('is_pinned'); |
66 | 66 | } |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param bool $pinned |
70 | 70 | * @return $this |
71 | 71 | */ |
72 | - public function setPinned (bool $pinned) { |
|
72 | + public function setPinned(bool $pinned) { |
|
73 | 73 | return $this->_set('is_pinned', $pinned); |
74 | 74 | } |
75 | 75 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'parent' => Task::class |
33 | 33 | ]; |
34 | 34 | |
35 | - final public function __toString (): string { |
|
35 | + final public function __toString(): string { |
|
36 | 36 | return "attachments/{$this->getGid()}"; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $file |
43 | 43 | * @return $this |
44 | 44 | */ |
45 | - public function upload (string $file) { |
|
45 | + public function upload(string $file) { |
|
46 | 46 | // api returns compact version. reload. |
47 | 47 | $remote = $this->api->upload("{$this->getParent()}/attachments", $file); |
48 | 48 | $this->data['gid'] = $remote['gid']; |