TimberCommand   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 9
lcom 0
cbo 1
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clear_cache_timber() 0 4 1
A clear_cache_twig() 0 4 1
B clear_cache() 0 16 7
1
<?php
2
3
/**
4
 * These are methods that can be executed by WPCLI, other CLI mechanism or other external controllers
5
 * @package  timber
6
 */
7
class TimberCommand {
8
9
    public static function clear_cache($mode = 'all'){
10
        if (is_array($mode)){
11
            $mode = reset($mode);
12
        }
13
        if ($mode == 'all') {
14
            $twig_cache = self::clear_cache_twig();
15
            $timber_cache = self::clear_cache_timber();
16
            if ($twig_cache && $timber_cache){
17
                return true;
18
            }
19
        } else if ($mode == 'twig') {
20
            return self::clear_cache_twig();
21
        } else if ($mode == 'timber') {
22
            return self::clear_cache_timber();
23
        }
24
    }
25
26
    static function clear_cache_timber(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
27
        $loader = new TimberLoader();
28
        return $loader->clear_cache_timber();
29
    }
30
31
    static function clear_cache_twig(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
        $loader = new TimberLoader();
33
        return $loader->clear_cache_twig();
34
    }
35
36
}
37