XCache::doFlush()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
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