@@ -12,5 +12,5 @@ |
||
12 | 12 | * @param string $path |
13 | 13 | * @param null|array $data |
14 | 14 | */ |
15 | - public function log (string $message, string $path, array $data = null): void; |
|
15 | + public function log(string $message, string $path, array $data = null): void; |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @param PSR16 $psr |
36 | 36 | */ |
37 | - public function __construct (PSR16 $psr) { |
|
37 | + public function __construct(PSR16 $psr) { |
|
38 | 38 | $this->psr = $psr; |
39 | 39 | $this->ttl = new DateInterval('PT1H'); |
40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $key |
44 | 44 | * @throws InvalidArgumentException |
45 | 45 | */ |
46 | - protected function _delete (string $key) { |
|
46 | + protected function _delete(string $key) { |
|
47 | 47 | $this->psr->delete('asana:' . $key); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return null|string|AbstractEntity |
53 | 53 | * @throws InvalidArgumentException |
54 | 54 | */ |
55 | - protected function _get (string $key) { |
|
55 | + protected function _get(string $key) { |
|
56 | 56 | return $this->psr->get('asana:' . $key); |
57 | 57 | } |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param mixed $value |
62 | 62 | * @throws InvalidArgumentException |
63 | 63 | */ |
64 | - protected function _set (string $key, $value) { |
|
64 | + protected function _set(string $key, $value) { |
|
65 | 65 | $this->psr->set('asana:' . $key, $value, $this->ttl); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | * @throws InvalidArgumentException |
72 | 72 | */ |
73 | - public function add (AbstractEntity $entity): bool { |
|
73 | + public function add(AbstractEntity $entity): bool { |
|
74 | 74 | if (parent::add($entity)) { |
75 | 75 | $this->_set($entity->getGid(), $entity); |
76 | 76 | return true; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string[] $keys |
84 | 84 | * @throws InvalidArgumentException |
85 | 85 | */ |
86 | - protected function addKeys (string $gid, array $keys): void { |
|
86 | + protected function addKeys(string $gid, array $keys): void { |
|
87 | 87 | parent::addKeys($gid, $keys); |
88 | 88 | // stash gid refs |
89 | 89 | foreach ($keys as $key) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return null|AbstractEntity |
101 | 101 | * @throws InvalidArgumentException |
102 | 102 | */ |
103 | - public function get (string $key, $caller, Closure $factory) { |
|
103 | + public function get(string $key, $caller, Closure $factory) { |
|
104 | 104 | // POOL MISS && CACHE HIT |
105 | 105 | if (!isset($this->gids[$key]) and $entity = $this->_get($key)) { |
106 | 106 | if ($entity instanceof AbstractEntity) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * @return DateInterval |
125 | 125 | */ |
126 | - public function getTtl () { |
|
126 | + public function getTtl() { |
|
127 | 127 | return $this->ttl; |
128 | 128 | } |
129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param AbstractEntity $entity |
132 | 132 | * @throws InvalidArgumentException |
133 | 133 | */ |
134 | - public function remove (AbstractEntity $entity): void { |
|
134 | + public function remove(AbstractEntity $entity): void { |
|
135 | 135 | parent::remove($entity); |
136 | 136 | foreach ($entity->getCacheKeys() as $key) { |
137 | 137 | $this->_delete($key); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param DateInterval $ttl |
143 | 143 | * @return $this |
144 | 144 | */ |
145 | - public function setTtl (DateInterval $ttl) { |
|
145 | + public function setTtl(DateInterval $ttl) { |
|
146 | 146 | $this->ttl = $ttl; |
147 | 147 | return $this; |
148 | 148 | } |
@@ -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 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param callable $spinner `fn( Job $this ): void` |
91 | 91 | * @return $this |
92 | 92 | */ |
93 | - public function wait (callable $spinner = null) { |
|
93 | + public function wait(callable $spinner = null) { |
|
94 | 94 | while (!$this->isDone()) { |
95 | 95 | if ($spinner) { |
96 | 96 | call_user_func($spinner, $this); |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | 'organization' => Workspace::class |
34 | 34 | ]; |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "organization_exports/{$this->getGid()}"; |
38 | 38 | } |
39 | 39 | |
40 | - final protected function _getDir (): string { |
|
40 | + final protected function _getDir(): string { |
|
41 | 41 | return "organization_exports"; |
42 | 42 | } |
43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param Workspace $organization |
46 | 46 | * @return $this |
47 | 47 | */ |
48 | - public function create (Workspace $organization) { |
|
48 | + public function create(Workspace $organization) { |
|
49 | 49 | $this->_set('organization', $organization); |
50 | 50 | return $this->_create(); |
51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool |
57 | 57 | */ |
58 | - public function isActive (): bool { |
|
58 | + public function isActive(): bool { |
|
59 | 59 | return $this->getState() === self::STATE_ACTIVE; |
60 | 60 | } |
61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public function isDone (): bool { |
|
67 | + public function isDone(): bool { |
|
68 | 68 | return $this->isSuccessful() or $this->isFailed(); |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool |
75 | 75 | */ |
76 | - public function isFailed (): bool { |
|
76 | + public function isFailed(): bool { |
|
77 | 77 | return $this->getState() === self::STATE_FAIL; |
78 | 78 | } |
79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - public function isQueued (): bool { |
|
85 | + public function isQueued(): bool { |
|
86 | 86 | return $this->getState() === self::STATE_QUEUED; |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return bool |
93 | 93 | */ |
94 | - public function isSuccessful (): bool { |
|
94 | + public function isSuccessful(): bool { |
|
95 | 95 | return $this->getState() === self::STATE_SUCCESS; |
96 | 96 | } |
97 | 97 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param callable $spinner `fn( OrganizationExport $this ): void` |
104 | 104 | * @return $this |
105 | 105 | */ |
106 | - public function wait (callable $spinner = null) { |
|
106 | + public function wait(callable $spinner = null) { |
|
107 | 107 | while (!$this->isDone()) { |
108 | 108 | if ($spinner) { |
109 | 109 | call_user_func($spinner, $this); |
@@ -12,14 +12,14 @@ |
||
12 | 12 | * |
13 | 13 | * @return string |
14 | 14 | */ |
15 | - abstract protected function _getDir (): string; |
|
15 | + abstract protected function _getDir(): string; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * `POST` the new entity to Asana. |
19 | 19 | * |
20 | 20 | * @return $this |
21 | 21 | */ |
22 | - public function create () { |
|
22 | + public function create() { |
|
23 | 23 | return $this->{'_save'}($this->_getDir()); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * `DELETE` |
12 | 12 | */ |
13 | - public function delete (): void { |
|
13 | + public function delete(): void { |
|
14 | 14 | $this->{'_delete'}(); |
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return $this |
14 | 14 | */ |
15 | - public function update () { |
|
15 | + public function update() { |
|
16 | 16 | return $this->{'_save'}(); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param Api|Data $caller |
48 | 48 | * @param array $data |
49 | 49 | */ |
50 | - public function __construct ($caller, array $data = []) { |
|
50 | + public function __construct($caller, array $data = []) { |
|
51 | 51 | $this->api = $caller instanceof self ? $caller->api : $caller; |
52 | 52 | $this->_setData($data); |
53 | 53 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * @param array $args |
64 | 64 | * @return mixed |
65 | 65 | */ |
66 | - public function __call (string $method, array $args) { |
|
66 | + public function __call(string $method, array $args) { |
|
67 | 67 | static $cache = []; |
68 | - if (!$call =& $cache[$method]) { |
|
68 | + if (!$call = & $cache[$method]) { |
|
69 | 69 | preg_match('/^(get|has|is|set)(.+)$/', $method, $call); |
70 | 70 | $call[1] = '_' . $call[1]; |
71 | 71 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return $this->{$call[1]}($call[2], ...$args); |
76 | 76 | } |
77 | 77 | |
78 | - public function __debugInfo (): array { |
|
78 | + public function __debugInfo(): array { |
|
79 | 79 | return $this->data; |
80 | 80 | } |
81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param $field |
86 | 86 | * @return null|Data|mixed |
87 | 87 | */ |
88 | - final public function __get ($field) { |
|
88 | + final public function __get($field) { |
|
89 | 89 | return $this->_get($field); |
90 | 90 | } |
91 | 91 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param $field |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - final public function __isset ($field) { |
|
100 | + final public function __isset($field) { |
|
101 | 101 | return true; |
102 | 102 | } |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param string $field |
110 | 110 | * @return mixed |
111 | 111 | */ |
112 | - protected function _get (string $field) { |
|
112 | + protected function _get(string $field) { |
|
113 | 113 | return $this->data[$field] ?? null; |
114 | 114 | } |
115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $field |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | - protected function _has (string $field): bool { |
|
126 | + protected function _has(string $field): bool { |
|
127 | 127 | $value = $this->_get($field); |
128 | 128 | if (isset($value)) { |
129 | 129 | if (is_countable($value)) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param string $field |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - protected function _is (string $field): bool { |
|
149 | + protected function _is(string $field): bool { |
|
150 | 150 | return !empty($this->_get($field)); |
151 | 151 | } |
152 | 152 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param mixed $value |
160 | 160 | * @return $this |
161 | 161 | */ |
162 | - protected function _set (string $field, $value) { |
|
162 | + protected function _set(string $field, $value) { |
|
163 | 163 | $this->data[$field] = $value; |
164 | 164 | $this->diff[$field] = true; |
165 | 165 | return $this; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param array $data |
172 | 172 | */ |
173 | - protected function _setData (array $data): void { |
|
173 | + protected function _setData(array $data): void { |
|
174 | 174 | $this->data = $this->diff = []; |
175 | 175 | foreach ($data as $field => $value) { |
176 | 176 | $this->_setMapped($field, $value); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param string $field |
184 | 184 | * @param mixed $value |
185 | 185 | */ |
186 | - protected function _setMapped (string $field, $value): void { |
|
186 | + protected function _setMapped(string $field, $value): void { |
|
187 | 187 | unset($this->diff[$field]); |
188 | 188 | |
189 | 189 | // use value as-is? |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $data |
232 | 232 | * @return mixed|Data|AbstractEntity |
233 | 233 | */ |
234 | - final protected function factory (string $class, array $data = []) { |
|
234 | + final protected function factory(string $class, array $data = []) { |
|
235 | 235 | return $this->api->factory($class, $this, $data); |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - public function getDiff (): array { |
|
243 | + public function getDiff(): array { |
|
244 | 244 | $convert = function($each) use (&$convert) { |
245 | 245 | // convert existing entities to gids |
246 | 246 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return bool |
267 | 267 | */ |
268 | - final public function isDiff (): bool { |
|
268 | + final public function isDiff(): bool { |
|
269 | 269 | return (bool)$this->diff; |
270 | 270 | } |
271 | 271 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @see toArray() |
274 | 274 | * @return array |
275 | 275 | */ |
276 | - public function jsonSerialize (): array { |
|
276 | + public function jsonSerialize(): array { |
|
277 | 277 | return $this->toArray(); |
278 | 278 | } |
279 | 279 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param array $query |
288 | 288 | * @return null|mixed|AbstractEntity |
289 | 289 | */ |
290 | - final protected function load (string $class, string $path, array $query = []) { |
|
290 | + final protected function load(string $class, string $path, array $query = []) { |
|
291 | 291 | return $this->api->load($class, $this, $path, $query); |
292 | 292 | } |
293 | 293 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param int $pages |
303 | 303 | * @return array|AbstractEntity[] |
304 | 304 | */ |
305 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
305 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
306 | 306 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
307 | 307 | } |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - public function serialize (): string { |
|
314 | + public function serialize(): string { |
|
315 | 315 | return json_encode($this); |
316 | 316 | } |
317 | 317 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @return array |
322 | 322 | */ |
323 | - public function toArray (): array { |
|
323 | + public function toArray(): array { |
|
324 | 324 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
325 | 325 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
326 | 326 | return $each->getGid(); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @param $serialized |
342 | 342 | */ |
343 | - public function unserialize ($serialized): void { |
|
343 | + public function unserialize($serialized): void { |
|
344 | 344 | $this->api = Api::getDefault(); |
345 | 345 | $data = json_decode($serialized, true); |
346 | 346 | $this->_setData($data); |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | if (is_array($class)) { |
219 | 219 | $class = $class[0]; |
220 | 220 | $this->data[$field] = array_map($hydrate, $value); |
221 | - } |
|
222 | - else { |
|
221 | + } else { |
|
223 | 222 | $this->data[$field] = $hydrate($value); |
224 | 223 | } |
225 | 224 | } |
@@ -324,11 +323,9 @@ discard block |
||
324 | 323 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
325 | 324 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
326 | 325 | return $each->getGid(); |
327 | - } |
|
328 | - elseif ($each instanceof self) { |
|
326 | + } elseif ($each instanceof self) { |
|
329 | 327 | return $each->toArray(); |
330 | - } |
|
331 | - elseif (is_array($each)) { |
|
328 | + } elseif (is_array($each)) { |
|
332 | 329 | return array_map($dehydrate, $each); |
333 | 330 | } |
334 | 331 | return $each; |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected $customField; |
35 | 35 | |
36 | - public function __construct (CustomField $customField, array $data = []) { |
|
36 | + public function __construct(CustomField $customField, array $data = []) { |
|
37 | 37 | parent::__construct($customField, $data); |
38 | 38 | $this->customField = $customField; |
39 | 39 | } |
40 | 40 | |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "enum_options/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
45 | - final protected function _getDir (): string { |
|
45 | + final protected function _getDir(): string { |
|
46 | 46 | return "{$this->customField}/enum_options"; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return CustomField |
51 | 51 | */ |
52 | - public function getCustomField () { |
|
52 | + public function getCustomField() { |
|
53 | 53 | return $this->customField; |
54 | 54 | } |
55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param EnumOption $option |
59 | 59 | * @return $this |
60 | 60 | */ |
61 | - public function moveAfter (EnumOption $option) { |
|
61 | + public function moveAfter(EnumOption $option) { |
|
62 | 62 | $this->api->post("{$this->_getDir()}/insert", [ |
63 | 63 | 'after_enum_option' => $option->getGid(), |
64 | 64 | 'enum_option' => $this->getGid() |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param EnumOption $option |
73 | 73 | * @return $this |
74 | 74 | */ |
75 | - public function moveBefore (EnumOption $option) { |
|
75 | + public function moveBefore(EnumOption $option) { |
|
76 | 76 | $this->api->post("{$this->_getDir()}/insert", [ |
77 | 77 | 'before_enum_option' => $option->getGid(), |
78 | 78 | 'enum_option' => $this->getGid() |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * @return $this |
86 | 86 | */ |
87 | - public function moveFirst () { |
|
87 | + public function moveFirst() { |
|
88 | 88 | $first = $this->customField->getEnumOptions()[0]; |
89 | 89 | if ($first !== $this) { |
90 | 90 | $this->moveBefore($first); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function moveLast () { |
|
98 | + public function moveLast() { |
|
99 | 99 | $options = $this->customField->getEnumOptions(); |
100 | 100 | $last = $options[count($options) - 1]; |
101 | 101 | if ($last !== $this) { |