Code Duplication    Length = 13-15 lines in 3 locations

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

@@ 147-159 (lines=13) @@
144
    /**
145
     * @return driverStatistic
146
     */
147
    public function getStats()
148
    {
149
        $info = $this->instance->info();
150
        $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0);
151
        $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0);
152
        $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date');
153
154
        return (new driverStatistic())
155
          ->setData(implode(', ', array_keys($this->itemInstances)))
156
          ->setRawData($info)
157
          ->setSize($size)
158
          ->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.", $version, $date->format(DATE_RFC2822)));
159
    }
160
}

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

@@ 167-181 (lines=15) @@
164
    /**
165
     * @return driverStatistic
166
     */
167
    public function getStats()
168
    {
169
        $stats = (array) $this->instance->getstats();
170
        $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0);
171
        $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion');
172
        $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0);
173
        
174
        $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]);
175
176
        return (new driverStatistic())
177
          ->setData(implode(', ', array_keys($this->itemInstances)))
178
          ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822)))
179
          ->setRawData($stats)
180
          ->setSize($stats[ 'bytes' ]);
181
    }
182
}

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

@@ 166-180 (lines=15) @@
163
    /**
164
     * @return driverStatistic
165
     */
166
    public function getStats()
167
    {
168
        $stats = (array) $this->instance->getStats();
169
        $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0);
170
        $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion');
171
        $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0);
172
173
        $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]);
174
175
        return (new driverStatistic())
176
          ->setData(implode(', ', array_keys($this->itemInstances)))
177
          ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822)))
178
          ->setRawData($stats)
179
          ->setSize($stats[ 'bytes' ]);
180
    }
181
}