Completed
Push — develop ( d73a05...7ce957 )
by Mike
07:24
created

ZendCacheFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Descriptor\Cache;
17
18
use Zend\Cache\Storage\Adapter\Filesystem;
19
use Zend\Cache\Storage\Plugin\PluginOptions;
20
use Zend\Cache\Storage\Plugin\Serializer as SerializerPlugin;
21
22
final class ZendCacheFactory
23
{
24
    public static function create()
25
    {
26
        $cache = new Filesystem();
27
        $cache->setOptions(
28
            [
29
                'namespace' => 'phpdoc-cache',
30
                'cache_dir' => sys_get_temp_dir(),
31
            ]
32
        );
33
        $plugin = new SerializerPlugin();
34
35
        if (extension_loaded('igbinary')) {
36
            $options = new PluginOptions();
37
            $options->setSerializer('igbinary');
38
39
            $plugin->setOptions($options);
40
        }
41
42
        $cache->addPlugin($plugin);
43
44
        return $cache;
45
    }
46
}
47