CacheUtility::enableCheck()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 6
nc 2
nop 1
1
<?php
2
/**
3
 * Cache utility
4
 *
5
 * @package CacheCheck\Utility
6
 * @author  Tim Lochmüller
7
 */
8
9
namespace HDNET\CacheCheck\Utility;
10
11
use HDNET\CacheCheck\Cache\Backend\CacheAnalyzerBackend;
12
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
13
14
/**
15
 * Cache utility
16
 *
17
 * @author Tim Lochmüller
18
 */
19
class CacheUtility
20
{
21
22
    /**
23
     * Enable the cache for the analysis
24
     *
25
     * @param string $cacheName
26
     *
27
     * @return void
28
     */
29
    public static function enableCheck($cacheName)
30
    {
31
        $backend = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$cacheName]['backend'];
32
        if (trim($backend) == '' || !class_exists($backend)) {
33
            $backend = Typo3DatabaseBackend::class;
34
        }
35
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$cacheName]['originalBackend'] = $backend;
36
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$cacheName]['backend'] = CacheAnalyzerBackend::class;
37
    }
38
}
39