2020use Generator ;
2121
2222use function is_int ;
23- use function is_iterable ;
2423use function is_object ;
25- use function is_string ;
2624
2725use Laudis \Neo4j \Exception \InvalidCacheArgumentException ;
2826
@@ -53,9 +51,7 @@ class Cache implements CacheInterface
5351 private array $ items = [];
5452 private static ?self $ instance = null ;
5553
56- private function __construct ()
57- {
58- }
54+ private function __construct () {}
5955
6056 public static function getInstance (): self
6157 {
@@ -69,7 +65,6 @@ public static function getInstance(): self
6965 /**
7066 * @template U
7167 *
72- * @param string $key
7368 * @param U $default
7469 *
7570 * @return T|U
@@ -102,8 +97,6 @@ public function clear(): bool
10297 */
10398 public function deleteMultiple (iterable $ keys ): bool
10499 {
105- $ this ->assertIterable ($ keys );
106-
107100 foreach ($ keys as $ key ) {
108101 $ this ->delete ($ key );
109102 }
@@ -122,10 +115,8 @@ public function set(string $key, mixed $value, int|DateInterval|null $ttl = null
122115 $ ttl = (new DateTimeImmutable ())->add ($ ttl )->getTimestamp ();
123116 } elseif ($ ttl === null ) {
124117 $ ttl = PHP_INT_MAX ;
125- } elseif (is_int ($ ttl )) {
126- $ ttl += time ();
127118 } else {
128- throw new InvalidCacheArgumentException ();
119+ $ ttl += time ();
129120 }
130121
131122 if (is_object ($ value )) {
@@ -150,14 +141,12 @@ public function delete($key): bool
150141 * @template U
151142 *
152143 * @param iterable<string> $keys
153- * @param U $default
144+ * @param U $default
154145 *
155146 * @return Generator<string, T|U>
156147 */
157148 public function getMultiple ($ keys , $ default = null ): Generator
158149 {
159- $ this ->assertIterable ($ keys );
160-
161150 /** @var list<string> $cachedKeys */
162151 $ cachedKeys = [];
163152 foreach ($ keys as $ key ) {
@@ -173,18 +162,16 @@ public function getMultiple($keys, $default = null): Generator
173162 }
174163
175164 /**
176- * @param iterable<string, T> $values
165+ * @param iterable<string, T> $values
177166 * @param int|DateInterval|null $ttl
178167 *
179168 * @throws InvalidCacheArgumentException
180169 */
181170 public function setMultiple (iterable $ values , null |int |DateInterval $ ttl = null ): bool
182171 {
183- $ this ->assertIterable ($ values );
184-
185172 foreach ($ values as $ key => $ value ) {
186173 if (is_int ($ key )) {
187- $ key = (string )$ key ;
174+ $ key = (string ) $ key ;
188175 }
189176 $ this ->set ($ key , $ value , $ ttl );
190177 }
0 commit comments