@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected $types = []; |
41 | 41 | |
42 | - public function __construct (Task $task, array $data = []) { |
|
42 | + public function __construct(Task $task, array $data = []) { |
|
43 | 43 | $this->task = $task; |
44 | 44 | parent::__construct($task, $data); |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @param array[] $values |
49 | 49 | */ |
50 | - protected function _setData (array $values): void { |
|
50 | + protected function _setData(array $values): void { |
|
51 | 51 | // ensure data is keyed by field gid |
52 | 52 | $values = array_combine(array_column($values, 'gid'), $values); |
53 | 53 | parent::_setData($values); |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @return int |
58 | 58 | */ |
59 | - public function count () { |
|
59 | + public function count() { |
|
60 | 60 | return count($this->data); |
61 | 61 | } |
62 | 62 | |
63 | - public function getDiff (): array { |
|
63 | + public function getDiff(): array { |
|
64 | 64 | return array_map(function(FieldValue $value) { |
65 | 65 | return $value->getValue(); |
66 | 66 | }, array_intersect_key($this->data, $this->diff)); |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param $fieldGid |
71 | 71 | * @return FieldValue |
72 | 72 | */ |
73 | - public function getField ($fieldGid) { |
|
73 | + public function getField($fieldGid) { |
|
74 | 74 | return $this->data[$fieldGid]; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return Generator |
79 | 79 | */ |
80 | - public function getIterator () { |
|
80 | + public function getIterator() { |
|
81 | 81 | foreach ($this->data as $field) { |
82 | 82 | yield $this[$field['gid']]; |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string $fieldGid |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function offsetExists ($fieldGid) { |
|
90 | + public function offsetExists($fieldGid) { |
|
91 | 91 | return array_key_exists($fieldGid, $this->data); |
92 | 92 | } |
93 | 93 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param string $fieldGid |
96 | 96 | * @return null|number|string |
97 | 97 | */ |
98 | - public function offsetGet ($fieldGid) { |
|
98 | + public function offsetGet($fieldGid) { |
|
99 | 99 | return $this->data[$fieldGid]->getValue(); |
100 | 100 | } |
101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $fieldGid |
104 | 104 | * @param null|number|string $value |
105 | 105 | */ |
106 | - public function offsetSet ($fieldGid, $value) { |
|
106 | + public function offsetSet($fieldGid, $value) { |
|
107 | 107 | $this->data[$fieldGid]->setValue($value); |
108 | 108 | $this->diff[$fieldGid] = true; |
109 | 109 | $this->task->diff['custom_fields'] = true; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param string $fieldGid |
116 | 116 | */ |
117 | - public function offsetUnset ($fieldGid) { |
|
117 | + public function offsetUnset($fieldGid) { |
|
118 | 118 | $this->offsetSet($fieldGid, null); |
119 | 119 | } |
120 | 120 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected $owner; |
28 | 28 | |
29 | - public function __construct (Data $owner, array $data = []) { |
|
29 | + public function __construct(Data $owner, array $data = []) { |
|
30 | 30 | $this->owner = $owner; |
31 | 31 | parent::__construct($owner, $data); |
32 | 32 | } |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public function getCurrentOptionName () { |
|
37 | + public function getCurrentOptionName() { |
|
38 | 38 | return $this->getEnumOptionNames()[$this->getValue()]; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | - public function getCustomFieldGid () { |
|
44 | + public function getCustomFieldGid() { |
|
45 | 45 | return $this->data['gid']; |
46 | 46 | } |
47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string[] |
52 | 52 | */ |
53 | - public function getEnumOptionNames () { |
|
53 | + public function getEnumOptionNames() { |
|
54 | 54 | static $names = []; // shared |
55 | 55 | $gid = $this->data['gid']; |
56 | 56 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string[] |
63 | 63 | */ |
64 | - public function getEnumOptionValues () { |
|
64 | + public function getEnumOptionValues() { |
|
65 | 65 | static $values = []; // shared |
66 | 66 | $gid = $this->data['gid']; |
67 | 67 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @return null|number|string |
72 | 72 | */ |
73 | - public function getValue () { |
|
73 | + public function getValue() { |
|
74 | 74 | $type = $this->data['type']; |
75 | 75 | if ($type === CustomField::TYPE_ENUM) { |
76 | 76 | return $this->data['enum_value']['gid'] ?? null; |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | return $this->data["{$type}_value"]; |
79 | 79 | } |
80 | 80 | |
81 | - final public function isEnum (): bool { |
|
81 | + final public function isEnum(): bool { |
|
82 | 82 | return $this->getType() === CustomField::TYPE_ENUM; |
83 | 83 | } |
84 | 84 | |
85 | - final public function isNumber (): bool { |
|
85 | + final public function isNumber(): bool { |
|
86 | 86 | return $this->getType() === CustomField::TYPE_NUMBER; |
87 | 87 | } |
88 | 88 | |
89 | - final public function isText (): bool { |
|
89 | + final public function isText(): bool { |
|
90 | 90 | return $this->getType() === CustomField::TYPE_TEXT; |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param null|number|string $value |
95 | 95 | * @return $this |
96 | 96 | */ |
97 | - public function setValue ($value) { |
|
97 | + public function setValue($value) { |
|
98 | 98 | $type = $this->data['type']; |
99 | 99 | $this->diff["{$type}_value"] = true; |
100 | 100 | if ($type === CustomField::TYPE_ENUM) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public function toArray (): array { |
|
113 | + public function toArray(): array { |
|
114 | 114 | // only strip if needed. |
115 | 115 | if (!isset($this->data['resource_subtype'])) { |
116 | 116 | return $this->data; |
@@ -25,31 +25,31 @@ discard block |
||
25 | 25 | */ |
26 | 26 | private $logger; |
27 | 27 | |
28 | - public function __construct (string $dir, LoggerInterface $logger) { |
|
28 | + public function __construct(string $dir, LoggerInterface $logger) { |
|
29 | 29 | $this->dir = $dir; |
30 | 30 | $this->logger = $logger; |
31 | 31 | } |
32 | 32 | |
33 | - private function _path ($key) { |
|
33 | + private function _path($key) { |
|
34 | 34 | $file = "{$this->dir}/{$key}~"; |
35 | 35 | clearstatcache(true, $file); |
36 | 36 | return $file; |
37 | 37 | } |
38 | 38 | |
39 | - public function clear () { |
|
39 | + public function clear() { |
|
40 | 40 | // unused |
41 | 41 | } |
42 | 42 | |
43 | - public function delete ($key) { |
|
43 | + public function delete($key) { |
|
44 | 44 | $this->logger->log('CACHE DELETE', $key); |
45 | 45 | unlink($this->_path($key)); |
46 | 46 | } |
47 | 47 | |
48 | - public function deleteMultiple ($keys) { |
|
48 | + public function deleteMultiple($keys) { |
|
49 | 49 | // unused |
50 | 50 | } |
51 | 51 | |
52 | - public function get ($key, $default = null) { |
|
52 | + public function get($key, $default = null) { |
|
53 | 53 | $file = $this->_path($key); |
54 | 54 | if (file_exists($file)) { |
55 | 55 | if (filemtime($file) > time()) { |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | return $default; |
66 | 66 | } |
67 | 67 | |
68 | - public function getMultiple ($keys, $default = null) { |
|
68 | + public function getMultiple($keys, $default = null) { |
|
69 | 69 | // unused |
70 | 70 | } |
71 | 71 | |
72 | - public function has ($key) { |
|
72 | + public function has($key) { |
|
73 | 73 | // unused |
74 | 74 | } |
75 | 75 | |
76 | - public function set ($key, $value, $ttl = null) { |
|
76 | + public function set($key, $value, $ttl = null) { |
|
77 | 77 | assert($ttl instanceof DateInterval); |
78 | 78 | $this->logger->log('CACHE SET', $key); |
79 | 79 | $path = $this->_path($key); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | touch($path, (new DateTime())->add($ttl)->getTimeStamp()); |
94 | 94 | } |
95 | 95 | |
96 | - public function setMultiple ($values, $ttl = null) { |
|
96 | + public function setMultiple($values, $ttl = null) { |
|
97 | 97 | // unused |
98 | 98 | } |
99 | 99 | } |
100 | 100 | \ No newline at end of file |
@@ -58,8 +58,7 @@ |
||
58 | 58 | } |
59 | 59 | $this->logger->log('CACHE EXPIRE', $key); |
60 | 60 | unlink($file); |
61 | - } |
|
62 | - else { |
|
61 | + } else { |
|
63 | 62 | $this->logger->log('CACHE MISS', $key); |
64 | 63 | } |
65 | 64 | return $default; |
@@ -40,15 +40,15 @@ 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 | |
51 | - protected function _setData (array $data): void { |
|
51 | + protected function _setData(array $data): void { |
|
52 | 52 | // deprecated for resource_subtype. also removing to conceptually separate from FieldValue |
53 | 53 | unset($data['type']); |
54 | 54 | parent::_setData($data); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param string $name |
63 | 63 | * @return EnumOption |
64 | 64 | */ |
65 | - public function addEnumOption (string $name) { |
|
65 | + public function addEnumOption(string $name) { |
|
66 | 66 | /** @var EnumOption $option */ |
67 | 67 | $option = $this->_factory(EnumOption::class); |
68 | 68 | $option->setName($name); |
@@ -78,35 +78,35 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public function hasNotificationsEnabled (): bool { |
|
81 | + public function hasNotificationsEnabled(): bool { |
|
82 | 82 | return $this->_is('has_notifications_enabled'); |
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - final public function isEnum (): bool { |
|
88 | + final public function isEnum(): bool { |
|
89 | 89 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public function isGlobalToWorkspace (): bool { |
|
95 | + public function isGlobalToWorkspace(): bool { |
|
96 | 96 | return $this->_is('is_global_to_workspace'); |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return bool |
101 | 101 | */ |
102 | - final public function isNumber (): bool { |
|
102 | + final public function isNumber(): bool { |
|
103 | 103 | return $this->getResourceSubtype() === self::TYPE_NUMBER; |
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - final public function isText (): bool { |
|
109 | + final public function isText(): bool { |
|
110 | 110 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
111 | 111 | } |
112 | 112 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param bool $flag |
115 | 115 | * @return $this |
116 | 116 | */ |
117 | - public function setGlobalToWorkspace (bool $flag) { |
|
117 | + public function setGlobalToWorkspace(bool $flag) { |
|
118 | 118 | return $this->_set('is_global_to_workspace', $flag); |
119 | 119 | } |
120 | 120 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param bool $flag |
123 | 123 | * @return $this |
124 | 124 | */ |
125 | - public function setNotificationsEnabled (bool $flag) { |
|
125 | + public function setNotificationsEnabled(bool $flag) { |
|
126 | 126 | return $this->_set('has_notifications_enabled', $flag); |
127 | 127 | } |
128 | 128 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param callable $cmp `fn( EnumOption $a, EnumOption $b ): int` |
131 | 131 | * @return $this |
132 | 132 | */ |
133 | - public function sortEnumOptions (callable $cmp) { |
|
133 | + public function sortEnumOptions(callable $cmp) { |
|
134 | 134 | if ($options = $this->getEnumOptions()) { |
135 | 135 | $prev = $options[0]; // first option on remote |
136 | 136 | usort($options, $cmp); |