Timber_WP_CLI_Command   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 52
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clear_cache() 0 3 1
A clear_cache_twig() 0 8 2
A clear_cache_timber() 0 11 2
1
<?php
2
if (!class_exists('WP_CLI_Command')) {
3
	return;
4
}
5
6
class Timber_WP_CLI_Command extends WP_CLI_Command {
7
8
    /**
9
     * Clears Timber and Twig's Cache
10
     *
11
     * ## EXAMPLES
12
     *
13
     *    wp timber clear_cache
14
     *
15
     */
16
    public function clear_cache($mode = 'all') {
17
        TimberCommand::clear_cache($mode);
18
    }
19
20
    /**
21
     * Clears Twig's Cache
22
     *
23
     * ## EXAMPLES
24
     *
25
     *    wp timber clear_cache_twig
26
     *
27
     */
28
    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...
29
        $clear = TimberCommand::clear_cache_twig();
30
        if ($clear){
31
            WP_CLI::success('Cleared contents of twig cache');
32
        } else {
33
            WP_CLI::warning('Failed to clear twig cache');
34
        }
35
    }
36
37
    /**
38
     * Clears Timber's Cache
39
     *
40
     * ## EXAMPLES
41
     *
42
     *    wp timber clear_cache_timber
43
     *
44
     */
45
    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...
46
        $clear = TimberCommand::clear_cache_timber();
47
        $message = 'Failed to clear timber cache';
48
        if ($clear){
49
            $message = "Cleared contents of Timber's Cache";
50
            WP_CLI::success($message);
51
        } else {
52
            WP_CLI::warning($message);
53
        }
54
        return $message;
55
    }
56
57
}
58