Passed
Branch master (748c89)
by Schlaefer
02:28
created

Plugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A onPluginsLoaded() 0 9 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 28
    public function onPluginsLoaded()
28
    {
29 28
        $storage = $this->settings['storage'];
30 28
        $config = $this->settings;
31 28
        unset($config['active'], $config['storage']);
32 28
        $psr16Cache = new \phpFastCache\Helper\Psr16Adapter($storage, $config);
33
34 28
        $phileCache = new PhileToPsr16CacheAdapter($psr16Cache);
35 28
        ServiceLocator::registerService('Phile_Cache', $phileCache);
36 28
    }
37
}
38