for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Germania\CacheServiceProvider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use phpFastCache\CacheManager;
class CacheServiceProvider implements ServiceProviderInterface
{
public $cache_lifetime;
public $cache_dir;
public function __construct($cache_dir = null, $cache_lifetime = 3600)
$this->cache_dir = $cache_dir ?: sys_get_temp_dir();
$this->cache_lifetime = (int) $cache_lifetime;
}
/**
* @implements ServiceProviderInterface
*/
public function register(Container $dic)
$dic['Cache.lifetime'] = function($dic) {
$dic
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return $this->cache_lifetime;
};
$dic['Cache.directory'] = function($dic) {
return $this->cache_dir;
$dic['Cache.ItemPool'] = function($dic) {
$cache_dir = $dic['Cache.directory'];
if (!$cache_dir) {
throw new \Exception("Cache directory not available: " . $cache_dir);
if (!is_writable( $cache_dir)) {
throw new \Exception("Cache directory not writeable: $cache_dir");
return CacheManager::getInstance('files', [ "path" => $cache_dir ]);
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.