@@ -39,8 +39,7 @@ |
||
39 | 39 | try { |
40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
41 | 41 | return $colors[array_rand($colors)]; |
42 | - } |
|
43 | - catch (Exception $exception) { |
|
42 | + } catch (Exception $exception) { |
|
44 | 43 | return 'none'; // unreachable |
45 | 44 | } |
46 | 45 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * @return string |
37 | 37 | */ |
38 | - public static function random (): string { |
|
38 | + public static function random(): string { |
|
39 | 39 | try { |
40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
41 | 41 | return $colors[array_rand($colors)]; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | const NAME = 'asana'; |
19 | 19 | |
20 | - public function boot () { |
|
20 | + public function boot() { |
|
21 | 21 | $this->publishes([ |
22 | 22 | __DIR__ . '/config/asana.php' => $this->app->configPath('asana.php') |
23 | 23 | ]); |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | - public function provides () { |
|
33 | + public function provides() { |
|
34 | 34 | return [self::NAME]; |
35 | 35 | } |
36 | 36 | |
37 | - public function register () { |
|
37 | + public function register() { |
|
38 | 38 | $this->app->singleton(self::NAME, function(Application $app) { |
39 | 39 | $config = $app['config'][self::NAME]; |
40 | 40 | $pool = null; |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | $this->_log("CACHE DELINK {$key}"); |
59 | 59 | unlink($ref); |
60 | 60 | unlink($path); |
61 | - } |
|
62 | - elseif (is_file($path)) { |
|
61 | + } elseif (is_file($path)) { |
|
63 | 62 | $this->_log("CACHE DELETE {$key}"); |
64 | 63 | unlink($path); |
65 | 64 | } |
@@ -117,8 +116,7 @@ discard block |
||
117 | 116 | ["CACHE SET {$key}", "CACHE BURN {$key}"][$value instanceof ImmutableInterface], |
118 | 117 | "CACHE UPDATE {$key}" |
119 | 118 | ][is_file($path)]); |
120 | - } |
|
121 | - else { |
|
119 | + } else { |
|
122 | 120 | $this->_log([ |
123 | 121 | "CACHE LINK {$key} => {$value}", |
124 | 122 | "CACHE RENEW LINK {$key} => {$value}" |
@@ -29,30 +29,30 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @param string $dir |
31 | 31 | */ |
32 | - public function __construct (string $dir) { |
|
32 | + public function __construct(string $dir) { |
|
33 | 33 | $this->dir = $dir; |
34 | 34 | $this->log = new NullLogger(); |
35 | 35 | } |
36 | 36 | |
37 | - private function _log (string $msg): void { |
|
37 | + private function _log(string $msg): void { |
|
38 | 38 | $this->log->log(LOG_DEBUG, $msg); |
39 | 39 | } |
40 | 40 | |
41 | - private function _path ($key): string { |
|
41 | + private function _path($key): string { |
|
42 | 42 | $path = "{$this->dir}/{$key}~"; |
43 | 43 | clearstatcache(true, $path); |
44 | 44 | return $path; |
45 | 45 | } |
46 | 46 | |
47 | - private function _ref ($key): string { |
|
47 | + private function _ref($key): string { |
|
48 | 48 | return "{$this->dir}/{$key}.ref"; |
49 | 49 | } |
50 | 50 | |
51 | - public function clear () { |
|
51 | + public function clear() { |
|
52 | 52 | // unused. just delete the dir. |
53 | 53 | } |
54 | 54 | |
55 | - public function delete ($key) { |
|
55 | + public function delete($key) { |
|
56 | 56 | $path = $this->_path($key); |
57 | 57 | if (is_link($ref = $this->_ref($key))) { |
58 | 58 | $this->_log("CACHE DELINK {$key}"); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function deleteMultiple ($keys) { |
|
68 | + public function deleteMultiple($keys) { |
|
69 | 69 | // unused |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param mixed $default Unused. |
75 | 75 | * @return null|string|object |
76 | 76 | */ |
77 | - public function get ($key, $default = null) { |
|
77 | + public function get($key, $default = null) { |
|
78 | 78 | $path = $this->_path($key); |
79 | 79 | if (!is_file($path)) { |
80 | 80 | $this->_log("CACHE MISS {$key}"); |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | return $data; |
94 | 94 | } |
95 | 95 | |
96 | - public function getMultiple ($keys, $default = null) { |
|
96 | + public function getMultiple($keys, $default = null) { |
|
97 | 97 | // unused |
98 | 98 | } |
99 | 99 | |
100 | - public function has ($key): bool { |
|
100 | + public function has($key): bool { |
|
101 | 101 | return is_file($this->_path($key)); |
102 | 102 | } |
103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param int $ttl |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - public function set ($key, $value, $ttl = null): void { |
|
110 | + public function set($key, $value, $ttl = null): void { |
|
111 | 111 | $path = $this->_path($key); |
112 | 112 | if (!is_dir(dirname($path))) { |
113 | 113 | mkdir(dirname($path), 0770, true); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * @param LoggerInterface $log |
137 | 137 | * @return $this |
138 | 138 | */ |
139 | - public function setLog (LoggerInterface $log) { |
|
139 | + public function setLog(LoggerInterface $log) { |
|
140 | 140 | $this->log = $log; |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | - public function setMultiple ($values, $ttl = null) { |
|
144 | + public function setMultiple($values, $ttl = null) { |
|
145 | 145 | // unused |
146 | 146 | } |
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * `DELETE` |
16 | 16 | */ |
17 | - public function delete (): void { |
|
17 | + public function delete(): void { |
|
18 | 18 | $this->api->delete($this); |
19 | 19 | $this->api->getPool()->remove($this->getPoolKeys()); |
20 | 20 | } |
@@ -49,8 +49,7 @@ discard block |
||
49 | 49 | public function __construct ($caller, array $data = []) { |
50 | 50 | if ($caller instanceof self) { |
51 | 51 | $this->api = $caller->api; |
52 | - } |
|
53 | - else { |
|
52 | + } else { |
|
54 | 53 | $this->api = $caller; |
55 | 54 | } |
56 | 55 | $this->_setData($data); |
@@ -242,8 +241,7 @@ discard block |
||
242 | 241 | $value = array_map(function($each) use ($class) { |
243 | 242 | return $this->_hydrate($class[0], $each); |
244 | 243 | }, $value); |
245 | - } |
|
246 | - elseif (isset($value)) { |
|
244 | + } elseif (isset($value)) { |
|
247 | 245 | $value = $this->_hydrate($class, $value); |
248 | 246 | } |
249 | 247 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param Api|Data $caller |
47 | 47 | * @param array $data |
48 | 48 | */ |
49 | - public function __construct ($caller, array $data = []) { |
|
49 | + public function __construct($caller, array $data = []) { |
|
50 | 50 | if ($caller instanceof self) { |
51 | 51 | $this->api = $caller->api; |
52 | 52 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param array $args |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function __call (string $method, array $args) { |
|
72 | + public function __call(string $method, array $args) { |
|
73 | 73 | static $magic = []; |
74 | - if (!$call =& $magic[$method]) { |
|
74 | + if (!$call = & $magic[$method]) { |
|
75 | 75 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
76 | 76 | if ('_select' !== $call[1] = '_' . $call[1]) { // _select() calls getters |
77 | 77 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return array |
87 | 87 | * @internal pool, `var_export()` |
88 | 88 | */ |
89 | - final public function __debugInfo (): array { |
|
89 | + final public function __debugInfo(): array { |
|
90 | 90 | return $this->data; |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return null|Data|mixed |
96 | 96 | * @internal for `array_column()` |
97 | 97 | */ |
98 | - final public function __get ($field) { |
|
98 | + final public function __get($field) { |
|
99 | 99 | return $this->_get($field); |
100 | 100 | } |
101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | * @internal for `array_column()` |
106 | 106 | */ |
107 | - final public function __isset ($field) { |
|
107 | + final public function __isset($field) { |
|
108 | 108 | return true; // fields may be lazy-loaded or coalesced to null. |
109 | 109 | } |
110 | 110 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $field |
117 | 117 | * @return mixed |
118 | 118 | */ |
119 | - protected function _get (string $field) { |
|
119 | + protected function _get(string $field) { |
|
120 | 120 | return $this->data[$field] ?? null; |
121 | 121 | } |
122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param string $field |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - protected function _has (string $field): bool { |
|
134 | + protected function _has(string $field): bool { |
|
135 | 135 | $value = $this->_get($field); |
136 | 136 | if (isset($value)) { |
137 | 137 | if (is_countable($value)) { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param mixed $item |
150 | 150 | * @return mixed |
151 | 151 | */ |
152 | - protected function _hydrate (string $class, $item) { |
|
152 | + protected function _hydrate(string $class, $item) { |
|
153 | 153 | if (!isset($item) or $item instanceof self) { |
154 | 154 | return $item; |
155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string $field |
179 | 179 | * @return bool |
180 | 180 | */ |
181 | - protected function _is (string $field): bool { |
|
181 | + protected function _is(string $field): bool { |
|
182 | 182 | return (bool)$this->_get($field); |
183 | 183 | } |
184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param array $args |
197 | 197 | * @return array |
198 | 198 | */ |
199 | - protected function _select ($subject, callable $filter, ...$args) { |
|
199 | + protected function _select($subject, callable $filter, ...$args) { |
|
200 | 200 | if (is_string($subject)) { |
201 | 201 | $subject = $this->{'get' . $subject}(...$args) ?? []; |
202 | 202 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param mixed $value |
219 | 219 | * @return $this |
220 | 220 | */ |
221 | - protected function _set (string $field, $value) { |
|
221 | + protected function _set(string $field, $value) { |
|
222 | 222 | $this->data[$field] = $value; |
223 | 223 | $this->diff[$field] = true; |
224 | 224 | return $this; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @param array $data |
231 | 231 | */ |
232 | - protected function _setData (array $data): void { |
|
232 | + protected function _setData(array $data): void { |
|
233 | 233 | $this->data = $this->diff = []; |
234 | 234 | foreach ($data as $field => $value) { |
235 | 235 | $this->_setField($field, $value); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param string $field |
243 | 243 | * @param mixed $value |
244 | 244 | */ |
245 | - protected function _setField (string $field, $value): void { |
|
245 | + protected function _setField(string $field, $value): void { |
|
246 | 246 | if (isset(static::MAP[$field])) { |
247 | 247 | $class = static::MAP[$field]; |
248 | 248 | if (is_array($class)) { |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return bool |
265 | 265 | */ |
266 | - final public function isDiff (): bool { |
|
266 | + final public function isDiff(): bool { |
|
267 | 267 | return (bool)$this->diff; |
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | 271 | * @return array |
272 | 272 | */ |
273 | - public function jsonSerialize (): array { |
|
273 | + public function jsonSerialize(): array { |
|
274 | 274 | $data = $this->toArray(); |
275 | 275 | ksort($data); |
276 | 276 | return $data; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function serialize (): string { |
|
285 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
284 | + public function serialize(): string { |
|
285 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param bool $diff |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - public function toArray (bool $diff = false): array { |
|
294 | + public function toArray(bool $diff = false): array { |
|
295 | 295 | $dehydrate = function($each) use (&$dehydrate, $diff) { |
296 | 296 | // convert entities to gids |
297 | 297 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @param $serialized |
319 | 319 | */ |
320 | - public function unserialize ($serialized): void { |
|
320 | + public function unserialize($serialized): void { |
|
321 | 321 | $this->data = json_decode($serialized, true); |
322 | 322 | } |
323 | 323 | } |
324 | 324 | \ No newline at end of file |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @return $this |
18 | 18 | */ |
19 | - public function update () { |
|
19 | + public function update() { |
|
20 | 20 | if ($this->isDiff()) { |
21 | 21 | /** @var array $remote */ |
22 | 22 | $remote = $this->api->put($this, $this->toArray(true), ['expand' => 'this']); |
@@ -160,8 +160,7 @@ |
||
160 | 160 | $this->caller->__set($this->data['gid'], true); |
161 | 161 | if ($type === CustomField::TYPE_ENUM) { |
162 | 162 | $this->data['enum_value']['gid'] = $this->_toEnumOptionGid($value); |
163 | - } |
|
164 | - else { |
|
163 | + } else { |
|
165 | 164 | $this->data["{$type}_value"] = $value; |
166 | 165 | } |
167 | 166 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param Change|FieldEntries $caller |
32 | 32 | * @param array $data |
33 | 33 | */ |
34 | - public function __construct ($caller, array $data = []) { |
|
34 | + public function __construct($caller, array $data = []) { |
|
35 | 35 | $this->caller = $caller; |
36 | 36 | parent::__construct($caller, $data); |
37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function __toString (): string { |
|
42 | + public function __toString(): string { |
|
43 | 43 | if ($this->isEnum()) { |
44 | 44 | return (string)$this->getCurrentOptionName(); |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param array $data |
53 | 53 | */ |
54 | - protected function _setData (array $data): void { |
|
54 | + protected function _setData(array $data): void { |
|
55 | 55 | if (isset($data['resource_subtype'])) { // sentinel for bloat |
56 | 56 | $tiny = array_intersect_key($data, array_flip([ |
57 | 57 | 'gid', |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * @param null|string $value |
78 | 78 | * @return null|string |
79 | 79 | */ |
80 | - protected function _toEnumOptionGid ($value) { |
|
80 | + protected function _toEnumOptionGid($value) { |
|
81 | 81 | return $this->getEnumOptionValues()[$value] ?? $value; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - final public function getCurrentOptionName (): string { |
|
87 | + final public function getCurrentOptionName(): string { |
|
88 | 88 | return $this->getEnumOptionNames()[$this->getValue()]; |
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @return CustomField |
93 | 93 | */ |
94 | - public function getCustomField () { |
|
94 | + public function getCustomField() { |
|
95 | 95 | return $this->api->getCustomField($this->getGid()); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return string[] |
102 | 102 | */ |
103 | - final public function getEnumOptionNames () { |
|
103 | + final public function getEnumOptionNames() { |
|
104 | 104 | static $names = []; // shared |
105 | 105 | $gid = $this->data['gid']; |
106 | 106 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string[] |
113 | 113 | */ |
114 | - final public function getEnumOptionValues () { |
|
114 | + final public function getEnumOptionValues() { |
|
115 | 115 | static $values = []; // shared |
116 | 116 | $gid = $this->data['gid']; |
117 | 117 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return null|number|string |
122 | 122 | */ |
123 | - final public function getValue () { |
|
123 | + final public function getValue() { |
|
124 | 124 | $type = $this->data['type']; |
125 | 125 | if ($type === CustomField::TYPE_ENUM) { |
126 | 126 | return $this->data['enum_value']['gid'] ?? null; |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - final public function isEnum (): bool { |
|
134 | + final public function isEnum(): bool { |
|
135 | 135 | return $this->getType() === CustomField::TYPE_ENUM; |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @return bool |
140 | 140 | */ |
141 | - final public function isNumber (): bool { |
|
141 | + final public function isNumber(): bool { |
|
142 | 142 | return $this->getType() === CustomField::TYPE_NUMBER; |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - final public function isText (): bool { |
|
148 | + final public function isText(): bool { |
|
149 | 149 | return $this->getType() === CustomField::TYPE_TEXT; |
150 | 150 | } |
151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param null|number|string $value |
154 | 154 | * @return $this |
155 | 155 | */ |
156 | - final public function setValue ($value) { |
|
156 | + final public function setValue($value) { |
|
157 | 157 | if ($this->caller instanceof FieldEntries) { // read-only if the entry is in an event change. |
158 | 158 | $type = $this->data['type']; |
159 | 159 | $this->diff["{$type}_value"] = true; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | 'user' => User::class |
19 | 19 | ]; |
20 | 20 | |
21 | - protected function _setData (array $data): void { |
|
21 | + protected function _setData(array $data): void { |
|
22 | 22 | // useless. likes aren't entities. |
23 | 23 | unset($data['gid'], $data['resource_type']); |
24 | 24 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | 'custom_field' => CustomField::class, |
24 | 24 | ]; |
25 | 25 | |
26 | - protected function _setData (array $data): void { |
|
26 | + protected function _setData(array $data): void { |
|
27 | 27 | // these are the only fields that matter. |
28 | 28 | parent::_setData([ |
29 | 29 | 'custom_field' => $data['custom_field'], |