Code Duplication    Length = 31-33 lines in 2 locations

src/FileCache.php 2 locations

@@ 294-324 (lines=31) @@
291
     *
292
     * @return  bool
293
     */
294
    private function setXattr($name, $data, $ttl) {
295
296
        $cacheFile = $name.".cache";
297
298
        $cached = file_put_contents($cacheFile, $data, LOCK_EX);
299
300
        if ( $cached === false ) {
301
302
            $this->raiseError("Error writing cache object (File), exiting gracefully", pathinfo($cacheFile));
303
304
            $this->setErrorState();
305
306
            return false;
307
308
        }
309
310
        $tagged = xattr_set($cacheFile, "EXPIRE", $ttl, XATTR_DONTFOLLOW);
311
312
        if ( $tagged === false ) {
313
314
            $this->raiseError("Error writing cache ttl (File) (XATTR), exiting gracefully", pathinfo($cacheFile));
315
316
            $this->setErrorState();
317
318
            return false;
319
320
        }
321
322
        return true;
323
324
    }
325
326
    /**
327
     * Set a cache element using ghost file
@@ 335-367 (lines=33) @@
332
     *
333
     * @return  bool
334
     */
335
    private function setGhost($name, $data, $ttl) {
336
337
        $cacheFile = $name.".cache";
338
339
        $cacheGhost = $name.".expire";
340
341
        $cached = file_put_contents($cacheFile, $data, LOCK_EX);
342
        
343
        if ( $cached === false ) {
344
345
            $this->raiseError("Error writing cache object (File), exiting gracefully", pathinfo($cacheFile));
346
347
            $this->setErrorState();
348
349
            return false;
350
351
        }
352
353
        $tagged = file_put_contents($cacheGhost, $ttl, LOCK_EX);
354
355
        if ( $tagged === false ) {
356
357
            $this->raiseError("Error writing cache ttl (File) (GHOST), exiting gracefully", pathinfo($cacheGhost));
358
359
            $this->setErrorState();
360
361
            return false;
362
363
        }
364
365
        return true;
366
367
    }
368
369
    /**
370
     * Get a cache element using xattr