Passed
Push — develop ( bcf814...d07230 )
by Schlaefer
02:57
created

Plugin::onPluginsLoaded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Plugin class
4
 */
5
namespace Phile\Plugin\Phile\PhpFastCache;
6
7
use Phile\Core\ServiceLocator;
8
use Phile\Plugin\AbstractPlugin;
9
10
/**
11
 * Class Plugin
12
 * Default Phile cache engine
13
 *
14
 * @author  PhileCMS
15
 * @link    https://philecms.com
16
 * @license http://opensource.org/licenses/MIT
17
 * @package Phile\Plugin\Phile\PhpFastCache
18
 */
19
class Plugin extends AbstractPlugin
20
{
21
22
    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23
24
    /**
25
     * onPluginsLoaded method
26
     */
27 27
    public function onPluginsLoaded()
28
    {
29 27
        $storage = $this->settings['storage'];
30 27
        $config = $this->settings;
31 27
        unset($config['active'], $config['storage']);
32 27
        $psr16Cache = new \phpFastCache\Helper\Psr16Adapter($storage, $config);
33
34 27
        $phileCache = new PhileToPsr16CacheAdapter($psr16Cache);
35 27
        ServiceLocator::registerService('Phile_Cache', $phileCache);
36 27
    }
37
}
38