Code Duplication    Length = 13-15 lines in 3 locations

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

@@ 192-204 (lines=13) @@
189
    /**
190
     * @return DriverStatistic
191
     */
192
    public function getStats()
193
    {
194
        $info = $this->instance->info();
195
        $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0);
196
        $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0);
197
        $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date');
198
199
        return (new DriverStatistic())
200
          ->setData(implode(', ', array_keys($this->itemInstances)))
201
          ->setRawData($info)
202
          ->setSize($size)
203
          ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.",
204
            $version, $date->format(DATE_RFC2822)));
205
    }
206
}

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

@@ 188-202 (lines=15) @@
185
    /**
186
     * @return DriverStatistic
187
     */
188
    public function getStats()
189
    {
190
        $stats = current($this->instance->getStats());
191
        $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0);
192
        $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : $this->instance->getVersion());
193
        $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0);
194
195
        $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]);
196
197
        return (new DriverStatistic())
198
          ->setData(implode(', ', array_keys($this->itemInstances)))
199
          ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822)))
200
          ->setRawData($stats)
201
          ->setSize($stats[ 'bytes' ]);
202
    }
203
}

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

@@ 193-207 (lines=15) @@
190
    /**
191
     * @return DriverStatistic
192
     */
193
    public function getStats()
194
    {
195
        $stats = (array)$this->instance->getstats();
196
        $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0);
197
        $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion');
198
        $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0);
199
200
        $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]);
201
202
        return (new DriverStatistic())
203
          ->setData(implode(', ', array_keys($this->itemInstances)))
204
          ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822)))
205
          ->setRawData($stats)
206
          ->setSize($stats[ 'bytes' ]);
207
    }
208
}