DoctrineCouchbaseFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 33
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 9 1
A configureOptionResolver() 0 14 1
1
<?php
2
3
/*
4
 * This file is part of php-cache organization.
5
 *
6
 * (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\AdapterBundle\Factory;
13
14
use Cache\Adapter\Doctrine\DoctrineCachePool;
15
use Couchbase;
16
use Doctrine\Common\Cache\CouchbaseCache;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
final class DoctrineCouchbaseFactory extends AbstractDoctrineAdapterFactory
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getAdapter(array $config)
28
    {
29
        $couchbase = new Couchbase($config['host'], $config['user'], $config['password'], $config['bucket']);
30
31
        $client = new CouchbaseCache();
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\Common\Cache\CouchbaseCache has been deprecated with message: Couchbase SDK 1.x is now deprecated. Use \Doctrine\Common\Cache\CouchbaseBucketCache instead.
https://developer.couchbase.com/documentation/server/current/sdk/php/compatibility-versions-features.html

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
32
        $client->setCouchbase($couchbase);
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
            'user' => 'Administrator',
45
            'password' => 'password',
46
            'bucket' => 'default',
47
        ]);
48
49
        $resolver->setAllowedTypes('host', ['string']);
50
        $resolver->setAllowedTypes('user', ['string']);
51
        $resolver->setAllowedTypes('password', ['string']);
52
        $resolver->setAllowedTypes('bucket', ['string']);
53
    }
54
}
55