Code Duplication    Length = 13-14 lines in 6 locations

src/phpFastCache/Core/Pool/ExtendedCacheItemPoolTrait.php 6 locations

@@ 182-194 (lines=13) @@
179
    /**
180
     * @inheritdoc
181
     */
182
    public function incrementItemsByTag($tagName, $step = 1)
183
    {
184
        if (is_string($tagName) && is_int($step)) {
185
            foreach ($this->getItemsByTag($tagName) as $item) {
186
                $item->increment($step);
187
                $this->saveDeferred($item);
188
            }
189
190
            return $this->commit();
191
        } else {
192
            throw new InvalidArgumentException('$tagName must be a string and $step an integer');
193
        }
194
    }
195
196
    /**
197
     * @inheritdoc
@@ 215-228 (lines=14) @@
212
    /**
213
     * @inheritdoc
214
     */
215
    public function incrementItemsByTagsAll(array $tagNames, $step = 1)
216
    {
217
        if (is_int($step)) {
218
            $items = $this->getItemsByTagsAll($tagNames);
219
220
            foreach ($items as $key => $item) {
221
                $item->increment($step);
222
                $this->saveDeferred($item);
223
            }
224
            return $this->commit();
225
        } else {
226
            throw new InvalidArgumentException('$step must be an integer');
227
        }
228
    }
229
230
    /**
231
     * @inheritdoc
@@ 233-245 (lines=13) @@
230
    /**
231
     * @inheritdoc
232
     */
233
    public function decrementItemsByTag($tagName, $step = 1)
234
    {
235
        if (is_string($tagName) && is_int($step)) {
236
            foreach ($this->getItemsByTag($tagName) as $item) {
237
                $item->decrement($step);
238
                $this->saveDeferred($item);
239
            }
240
241
            return $this->commit();
242
        } else {
243
            throw new InvalidArgumentException('$tagName must be a string and $step an integer');
244
        }
245
    }
246
247
    /**
248
     * @inheritdoc
@@ 266-279 (lines=14) @@
263
    /**
264
     * @inheritdoc
265
     */
266
    public function decrementItemsByTagsAll(array $tagNames, $step = 1)
267
    {
268
        if (is_int($step)) {
269
            $items = $this->getItemsByTagsAll($tagNames);
270
271
            foreach ($items as $key => $item) {
272
                $item->decrement($step);
273
                $this->saveDeferred($item);
274
            }
275
            return $this->commit();
276
        } else {
277
            throw new InvalidArgumentException('$step must be an integer');
278
        }
279
    }
280
281
    /**
282
     * @inheritdoc
@@ 284-296 (lines=13) @@
281
    /**
282
     * @inheritdoc
283
     */
284
    public function appendItemsByTag($tagName, $data)
285
    {
286
        if (is_string($tagName)) {
287
            foreach ($this->getItemsByTag($tagName) as $item) {
288
                $item->append($data);
289
                $this->saveDeferred($item);
290
            }
291
292
            return $this->commit();
293
        } else {
294
            throw new InvalidArgumentException('$tagName must be a string');
295
        }
296
    }
297
298
    /**
299
     * @inheritdoc
@@ 335-347 (lines=13) @@
332
    /**
333
     * @inheritdoc
334
     */
335
    public function prependItemsByTag($tagName, $data)
336
    {
337
        if (is_string($tagName)) {
338
            foreach ($this->getItemsByTag($tagName) as $item) {
339
                $item->prepend($data);
340
                $this->saveDeferred($item);
341
            }
342
343
            return $this->commit();
344
        } else {
345
            throw new InvalidArgumentException('$tagName must be a string');
346
        }
347
    }
348
349
    /**
350
     * @inheritdoc