Code Duplication    Length = 30-30 lines in 3 locations

src/Factory/DoctrineMemcachedFactory.php 1 location

@@ 22-51 (lines=30) @@
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
final class DoctrineMemcachedFactory extends AbstractDoctrineAdapterFactory
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getAdapter(array $config)
28
    {
29
        $memcached = new Memcached();
30
        $memcached->addServer($config['host'], $config['port']);
31
32
        $client = new MemcachedCache();
33
        $client->setMemcached($memcached);
34
35
        return new DoctrineCachePool($client);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected static function configureOptionResolver(OptionsResolver $resolver)
42
    {
43
        $resolver->setDefaults([
44
            'host' => '127.0.0.1',
45
            'port' => '11211',
46
        ]);
47
48
        $resolver->setAllowedTypes('host', ['string']);
49
        $resolver->setAllowedTypes('port', ['string', 'int']);
50
    }
51
}
52

src/Factory/DoctrineMemcacheFactory.php 1 location

@@ 22-51 (lines=30) @@
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
final class DoctrineMemcacheFactory extends AbstractDoctrineAdapterFactory
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getAdapter(array $config)
28
    {
29
        $memcache = new Memcache();
30
        $memcache->connect($config['host'], $config['port']);
31
32
        $client = new MemcacheCache();
33
        $client->setMemcache($memcache);
34
35
        return new DoctrineCachePool($client);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected static function configureOptionResolver(OptionsResolver $resolver)
42
    {
43
        $resolver->setDefaults([
44
            'host' => '127.0.0.1',
45
            'port' => '11211',
46
        ]);
47
48
        $resolver->setAllowedTypes('host', ['string']);
49
        $resolver->setAllowedTypes('port', ['string', 'int']);
50
    }
51
}
52

src/Factory/DoctrineRedisFactory.php 1 location

@@ 21-50 (lines=30) @@
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
final class DoctrineRedisFactory extends AbstractDoctrineAdapterFactory
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getAdapter(array $config)
27
    {
28
        $redis = new \Redis();
29
        $redis->connect($config['host'], $config['port']);
30
31
        $client = new RedisCache();
32
        $client->setRedis($redis);
33
34
        return new DoctrineCachePool($client);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    protected static function configureOptionResolver(OptionsResolver $resolver)
41
    {
42
        $resolver->setDefaults([
43
            'host' => '127.0.0.1',
44
            'port' => '6379',
45
        ]);
46
47
        $resolver->setAllowedTypes('host', ['string']);
48
        $resolver->setAllowedTypes('port', ['string', 'int']);
49
    }
50
}
51