FileCacheAdapterFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 25
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createAdapter() 0 5 1
1
<?php
2
/**
3
 * File: FileCacheAdapterFactory.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\Otomoto\Middleware\Cache\Factory\File;
10
11
use MSlwk\Otomoto\Middleware\Cache\Adapter\CacheAdapter;
12
use MSlwk\Otomoto\Middleware\Cache\Adapter\CacheAdapterInterface;
13
use MSlwk\Otomoto\Middleware\Cache\Factory\CacheAdapterFactoryInterface;
14
use MSlwk\Otomoto\Middleware\Cache\Factory\File\OptionsProvider\FileDriverOptionsProviderInterface;
15
use Stash\Driver\FileSystem;
16
use Stash\Pool;
17
18
/**
19
 * Class FileCacheAdapterFactory
20
 * @package MSlwk\Otomoto\Middleware\Cache\Factory
21
 */
22
class FileCacheAdapterFactory implements CacheAdapterFactoryInterface
23
{
24
    /**
25
     * @var FileDriverOptionsProviderInterface
26
     */
27
    private $fileDriverOptionsProvider;
28
29
    /**
30
     * FileCacheAdapterFactory constructor.
31
     * @param FileDriverOptionsProviderInterface $fileDriverOptionsProvider
32
     */
33 6
    public function __construct(
34
        FileDriverOptionsProviderInterface $fileDriverOptionsProvider
35
    ) {
36 6
        $this->fileDriverOptionsProvider = $fileDriverOptionsProvider;
37 6
    }
38
39
    /**
40
     * @return CacheAdapterInterface
41
     */
42 6
    public function createAdapter(): CacheAdapterInterface
43
    {
44 6
        $driver = new FileSystem($this->fileDriverOptionsProvider->getOptions());
45 6
        $pool = new Pool($driver);
46 6
        return new CacheAdapter($pool);
47
    }
48
}
49