configureOptionResolver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
ccs 9
cts 9
cp 1
cc 1
nc 1
nop 1
crap 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\FilesystemCache;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
final class DoctrineFilesystemFactory extends AbstractDoctrineAdapterFactory
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function getAdapter(array $config)
27
    {
28 1
        $client = new FilesystemCache($config['directory'], $config['extension'], (int) $config['umask']);
29
30 1
        return new DoctrineCachePool($client);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 3
    protected static function configureOptionResolver(OptionsResolver $resolver)
37
    {
38 3
        $resolver->setDefaults([
39 3
            'extension' => FilesystemCache::EXTENSION,
40 3
            'umask' => '0002',
41
        ]);
42
43 3
        $resolver->setRequired(['directory']);
44
45 3
        $resolver->setAllowedTypes('directory', ['string']);
46 3
        $resolver->setAllowedTypes('extension', ['string']);
47 3
        $resolver->setAllowedTypes('umask', ['string', 'int']);
48 3
    }
49
}
50