@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public function getCurrentOptionName () { |
|
26 | + public function getCurrentOptionName() { |
|
27 | 27 | return $this->getEnumOptionNames()[$this->getValue()]; |
28 | 28 | } |
29 | 29 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return string[] |
34 | 34 | */ |
35 | - public function getEnumOptionNames () { |
|
35 | + public function getEnumOptionNames() { |
|
36 | 36 | static $names = []; // shared |
37 | 37 | $gid = $this->data['gid']; |
38 | 38 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return string[] |
45 | 45 | */ |
46 | - public function getEnumOptionValues () { |
|
46 | + public function getEnumOptionValues() { |
|
47 | 47 | static $values = []; // shared |
48 | 48 | $gid = $this->data['gid']; |
49 | 49 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return null|number|string |
54 | 54 | */ |
55 | - public function getValue () { |
|
55 | + public function getValue() { |
|
56 | 56 | $type = $this->data['type']; |
57 | 57 | if ($type === CustomField::TYPE_ENUM) { |
58 | 58 | return $this->data['enum_value']['gid'] ?? null; |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | return $this->data["{$type}_value"]; |
61 | 61 | } |
62 | 62 | |
63 | - final public function isEnum (): bool { |
|
63 | + final public function isEnum(): bool { |
|
64 | 64 | return $this->getType() === CustomField::TYPE_ENUM; |
65 | 65 | } |
66 | 66 | |
67 | - final public function isNumber (): bool { |
|
67 | + final public function isNumber(): bool { |
|
68 | 68 | return $this->getType() === CustomField::TYPE_NUMBER; |
69 | 69 | } |
70 | 70 | |
71 | - final public function isText (): bool { |
|
71 | + final public function isText(): bool { |
|
72 | 72 | return $this->getType() === CustomField::TYPE_TEXT; |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param null|number|string $value |
77 | 77 | * @return $this |
78 | 78 | */ |
79 | - public function setValue ($value) { |
|
79 | + public function setValue($value) { |
|
80 | 80 | $type = $this->data['type']; |
81 | 81 | $this->diff["{$type}_value"] = true; |
82 | 82 | if ($type === CustomField::TYPE_ENUM) { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return array |
94 | 94 | */ |
95 | - public function toArray (): array { |
|
95 | + public function toArray(): array { |
|
96 | 96 | // only strip if needed. |
97 | 97 | if (!isset($this->data['resource_subtype'])) { |
98 | 98 | return $this->data; |
@@ -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(FieldEntry $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 FieldEntry |
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 $gid => $field) { |
82 | 82 | yield $gid => $field->getValue(); |
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 |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | */ |
31 | 31 | private $logger; |
32 | 32 | |
33 | - public function __construct (string $dir) { |
|
33 | + public function __construct(string $dir) { |
|
34 | 34 | $this->dir = $dir; |
35 | 35 | } |
36 | 36 | |
37 | - private function _path ($key) { |
|
37 | + private function _path($key) { |
|
38 | 38 | $file = "{$this->dir}/{$key}~"; |
39 | 39 | clearstatcache(true, $file); |
40 | 40 | return $file; |
41 | 41 | } |
42 | 42 | |
43 | - public function clear () { |
|
43 | + public function clear() { |
|
44 | 44 | // unused. just delete the dir. |
45 | 45 | } |
46 | 46 | |
47 | - public function delete ($key) { |
|
47 | + public function delete($key) { |
|
48 | 48 | $path = $this->_path($key); |
49 | 49 | if (file_exists($path)) { |
50 | 50 | $this->log('CACHE DELETE', $key); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - public function deleteMultiple ($keys) { |
|
55 | + public function deleteMultiple($keys) { |
|
56 | 56 | // unused |
57 | 57 | } |
58 | 58 | |
59 | - public function get ($key, $default = null) { |
|
59 | + public function get($key, $default = null) { |
|
60 | 60 | $path = $this->_path($key); |
61 | 61 | if (file_exists($path)) { |
62 | 62 | if (filemtime($path) > time()) { |
@@ -75,32 +75,32 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @return LoggerInterface |
77 | 77 | */ |
78 | - public function getLogger () { |
|
78 | + public function getLogger() { |
|
79 | 79 | return $this->logger; |
80 | 80 | } |
81 | 81 | |
82 | - public function getMultiple ($keys, $default = null) { |
|
82 | + public function getMultiple($keys, $default = null) { |
|
83 | 83 | // unused |
84 | 84 | } |
85 | 85 | |
86 | - public function has ($key) { |
|
86 | + public function has($key) { |
|
87 | 87 | // unused |
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @return bool |
92 | 92 | */ |
93 | - public function isGzEncoding (): bool { |
|
93 | + public function isGzEncoding(): bool { |
|
94 | 94 | return $this->gzEncoding; |
95 | 95 | } |
96 | 96 | |
97 | - private function log (string $msg, string $key): void { |
|
97 | + private function log(string $msg, string $key): void { |
|
98 | 98 | if ($this->logger) { |
99 | 99 | $this->logger->log($msg, $key); |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - public function set ($key, $value, $ttl = null) { |
|
103 | + public function set($key, $value, $ttl = null) { |
|
104 | 104 | assert($ttl instanceof DateInterval); |
105 | 105 | $this->log('CACHE SET', $key); |
106 | 106 | $path = $this->_path($key); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param bool $gzEncoding |
125 | 125 | * @return $this |
126 | 126 | */ |
127 | - public function setGzEncoding (bool $gzEncoding) { |
|
127 | + public function setGzEncoding(bool $gzEncoding) { |
|
128 | 128 | $this->gzEncoding = $gzEncoding; |
129 | 129 | return $this; |
130 | 130 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @param null|LoggerInterface $logger |
134 | 134 | * @return $this |
135 | 135 | */ |
136 | - public function setLogger (?LoggerInterface $logger) { |
|
136 | + public function setLogger(?LoggerInterface $logger) { |
|
137 | 137 | $this->logger = $logger; |
138 | 138 | return $this; |
139 | 139 | } |
140 | 140 | |
141 | - public function setMultiple ($values, $ttl = null) { |
|
141 | + public function setMultiple($values, $ttl = null) { |
|
142 | 142 | // unused |
143 | 143 | } |
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -65,8 +65,7 @@ |
||
65 | 65 | } |
66 | 66 | $this->log('CACHE EXPIRE', $key); |
67 | 67 | unlink($path); |
68 | - } |
|
69 | - else { |
|
68 | + } else { |
|
70 | 69 | $this->log('CACHE MISS', $key); |
71 | 70 | } |
72 | 71 | return $default; |