XCache   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A doFlush() 0 14 2
1
<?php
2
/**
3
 * For the full copyright and license information, please view the LICENSE
4
 * file that was distributed with this source code.
5
 *
6
 * @author Igor Borodikhin <[email protected]>
7
 * @author Nikita Vershinin <[email protected]>
8
 * @license MIT
9
 */
10
namespace Endeveit\Cache\Drivers;
11
12
use Endeveit\Cache\Abstracts\InMemory;
13
14
/**
15
 * Driver that stores data in XCache and uses php5-xcache extension.
16
 */
17
class XCache extends InMemory
18
{
19
    /**
20
     * {@inheritdoc}
21
     *
22
     * @codeCoverageIgnore
23
     * @param array $options
24
     */
25
    public function __construct(array $options = array())
26
    {
27
        parent::__construct($options);
28
29
        $this->callbacks = array(
30
            'increment' => 'xcache_inc',
31
            'decrement' => 'xcache_dec',
32
            'exists'    => 'xcache_isset',
33
            'load'      => 'xcache_get',
34
            'save'      => 'xcache_set',
35
        );
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @return boolean
42
     */
43
    protected function doFlush()
44
    {
45
        if (ini_get('xcache.admin.enable_auth')) {
46
            // @codeCoverageIgnoreStart
47
            throw new \BadMethodCallException(
48
                'You must set "xcache.admin.enable_auth" to "Off" in your php.ini to flush cache items.'
49
            );
50
            // @codeCoverageIgnoreEnd
51
        }
52
53
        xcache_clear_cache(XC_TYPE_VAR, 0);
54
55
        return true;
56
    }
57
}
58