SessionHandlerFactory::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
3
/*
4
 * This file is part of php-cache\cache-bundle package.
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\CacheBundle\Factory;
13
14
use Cache\CacheBundle\Cache\FixedTaggingCachePool;
15
use Cache\SessionHandler\Psr6SessionHandler;
16
use Cache\Taggable\TaggablePSR6PoolAdapter;
17
use Psr\Cache\CacheItemPoolInterface;
18
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
class SessionHandlerFactory
23
{
24
    /**
25
     * @param CacheItemPoolInterface $pool
26
     * @param array                  $config
27
     *
28
     * @return Psr6SessionHandler
29
     */
30
    public static function get(CacheItemPoolInterface $pool, array $config)
31
    {
32
        if ($config['use_tagging']) {
33
            $pool = new FixedTaggingCachePool(TaggablePSR6PoolAdapter::makeTaggable($pool), ['session']);
34
        }
35
36
        return new Psr6SessionHandler($pool, $config);
37
    }
38
}
39