CacheUtility   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 3
c 4
b 1
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A enableCheck() 0 9 3
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