DoctrineSQLite3Factory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
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 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 6 1
A configureOptionResolver() 0 7 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 Doctrine\Common\Cache\SQLite3Cache;
16
use SQLite3;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
final class DoctrineSQLite3Factory extends AbstractDoctrineAdapterFactory
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getAdapter(array $config)
28
    {
29
        $sqlite = new SQLite3($config['file_path']);
30
31
        return new DoctrineCachePool(new SQLite3Cache($sqlite, $config['table']));
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected static function configureOptionResolver(OptionsResolver $resolver)
38
    {
39
        $resolver->setRequired(['file_path', 'table']);
40
41
        $resolver->setAllowedTypes('file_path', ['string']);
42
        $resolver->setAllowedTypes('table', ['string']);
43
    }
44
}
45