PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/google/auth/src/Cache/MemoryCacheItemPool.php +17 -18 1.0.01.4.1 View file →
@@ -14,12 +14,12 @@
14 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 15 * See the License for the specific language governing permissions and
16 16 * limitations under the License.
17 17 */
18 -namespace Dudlewebs\WPMCS\Google\Auth\Cache;
18 +namespace Dudlewebs\WPMCS\GCP\Google\Auth\Cache;
19 19
20 -use Dudlewebs\WPMCS\Psr\Cache\CacheItemInterface;
21 -use Dudlewebs\WPMCS\Psr\Cache\CacheItemPoolInterface;
20 +use Dudlewebs\WPMCS\GCP\Psr\Cache\CacheItemInterface;
21 +use Dudlewebs\WPMCS\GCP\Psr\Cache\CacheItemPoolInterface;
22 22 /**
23 23 * Simple in-memory cache implementation.
24 24 */
25 25 final class MemoryCacheItemPool implements CacheItemPoolInterface
@@ -36,11 +36,11 @@
36 36 * {@inheritdoc}
37 37 *
38 38 * @return CacheItemInterface The corresponding Cache Item.
39 39 */
40 - public function getItem($key): CacheItemInterface
40 + public function getItem($key) : CacheItemInterface
41 41 {
42 - return current($this->getItems([$key]));
42 + return \current($this->getItems([$key]));
43 43 // @phpstan-ignore-line
44 44 }
45 45 /**
46 46 * {@inheritdoc}
@@ -50,14 +50,13 @@
50 50 * each item. A Cache item will be returned for each key, even if that
51 51 * key is not found. However, if no keys are specified then an empty
52 52 * traversable MUST be returned instead.
53 53 */
54 - public function getItems(array $keys = []): iterable
54 + public function getItems(array $keys = []) : iterable
55 55 {
56 56 $items = [];
57 - $itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
58 57 foreach ($keys as $key) {
59 - $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new $itemClass($key);
58 + $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new TypedItem($key);
60 59 }
61 60 return $items;
62 61 }
63 62 /**
@@ -65,9 +64,9 @@
65 64 *
66 65 * @return bool
67 66 * True if item exists in the cache, false otherwise.
68 67 */
69 - public function hasItem($key): bool
68 + public function hasItem($key) : bool
70 69 {
71 70 $this->isValidKey($key);
72 71 return isset($this->items[$key]) && $this->items[$key]->isHit();
73 72 }
@@ -76,9 +75,9 @@
76 75 *
77 76 * @return bool
78 77 * True if the pool was successfully cleared. False if there was an error.
79 78 */
80 - public function clear(): bool
79 + public function clear() : bool
81 80 {
82 81 $this->items = [];
83 82 $this->deferredItems = [];
84 83 return \true;
@@ -88,9 +87,9 @@
88 87 *
89 88 * @return bool
90 89 * True if the item was successfully removed. False if there was an error.
91 90 */
92 - public function deleteItem($key): bool
91 + public function deleteItem($key) : bool
93 92 {
94 93 return $this->deleteItems([$key]);
95 94 }
96 95 /**
@@ -98,11 +97,11 @@
98 97 *
99 98 * @return bool
100 99 * True if the items were successfully removed. False if there was an error.
101 100 */
102 - public function deleteItems(array $keys): bool
101 + public function deleteItems(array $keys) : bool
103 102 {
104 - array_walk($keys, [$this, 'isValidKey']);
103 + \array_walk($keys, [$this, 'isValidKey']);
105 104 foreach ($keys as $key) {
106 105 unset($this->items[$key]);
107 106 }
108 107 return \true;
@@ -112,9 +111,9 @@
112 111 *
113 112 * @return bool
114 113 * True if the item was successfully persisted. False if there was an error.
115 114 */
116 - public function save(CacheItemInterface $item): bool
115 + public function save(CacheItemInterface $item) : bool
117 116 {
118 117 $this->items[$item->getKey()] = $item;
119 118 return \true;
120 119 }
@@ -123,9 +122,9 @@
123 122 *
124 123 * @return bool
125 124 * False if the item could not be queued or if a commit was attempted and failed. True otherwise.
126 125 */
127 - public function saveDeferred(CacheItemInterface $item): bool
126 + public function saveDeferred(CacheItemInterface $item) : bool
128 127 {
129 128 $this->deferredItems[$item->getKey()] = $item;
130 129 return \true;
131 130 }
@@ -134,9 +133,9 @@
134 133 *
135 134 * @return bool
136 135 * True if all not-yet-saved items were successfully saved or there were none. False otherwise.
137 136 */
138 - public function commit(): bool
137 + public function commit() : bool
139 138 {
140 139 foreach ($this->deferredItems as $item) {
141 140 $this->save($item);
142 141 }
@@ -152,10 +151,10 @@
152 151 */
153 152 private function isValidKey($key)
154 153 {
155 154 $invalidCharacters = '{}()/\\\\@:';
156 - if (!is_string($key) || preg_match("#[{$invalidCharacters}]#", $key)) {
157 - throw new InvalidArgumentException('The provided key is not valid: ' . var_export($key, \true));
155 + if (!\is_string($key) || \preg_match("#[{$invalidCharacters}]#", $key)) {
156 + throw new InvalidArgumentException('The provided key is not valid: ' . \var_export($key, \true));
158 157 }
159 158 return \true;
160 159 }
161 160 }