Code Duplication    Length = 19-21 lines in 2 locations

src/phpFastCache/Drivers/Memcache/Driver.php 1 location

@@ 75-93 (lines=19) @@
72
     * @return mixed
73
     * @throws phpFastCacheInvalidArgumentException
74
     */
75
    protected function driverWrite(CacheItemInterface $item)
76
    {
77
        /**
78
         * Check for Cross-Driver type confusion
79
         */
80
        if ($item instanceof Item) {
81
            $ttl = $item->getTtl();
82
83
            // Memcache will only allow a expiration timer less than 2592000 seconds,
84
            // otherwise, it will assume you're giving it a UNIX timestamp.
85
            if ($ttl >= 2592000) {
86
                $ttl = $item->getExpirationDate()->getTimestamp();
87
            }
88
89
            return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $this->memcacheFlags, $ttl);
90
        } else {
91
            throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
92
        }
93
    }
94
95
    /**
96
     * @param \Psr\Cache\CacheItemInterface $item

src/phpFastCache/Drivers/Memcached/Driver.php 1 location

@@ 66-86 (lines=21) @@
63
     * @return mixed
64
     * @throws phpFastCacheInvalidArgumentException
65
     */
66
    protected function driverWrite(CacheItemInterface $item)
67
    {
68
        /**
69
         * Check for Cross-Driver type confusion
70
         */
71
        if ($item instanceof Item) {
72
            $ttl = $item->getTtl();
73
74
            // Memcache will only allow a expiration timer less than 2592000 seconds,
75
            // otherwise, it will assume you're giving it a UNIX timestamp.
76
            if ($ttl >= 2592000) {
77
                $ttl = $item->getExpirationDate()->getTimestamp();
78
            }
79
80
            return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $ttl);
81
        } else {
82
            throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
83
        }
84
85
        return true;
86
    }
87
88
    /**
89
     * @param \Psr\Cache\CacheItemInterface $item