• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

timber / timber / 5690057835

pending completion
5690057835

push

github

nlemoine
Merge branch '2.x' of github.com:timber/timber into 2.x-refactor-file-models

# Conflicts:
#	src/Attachment.php
#	src/ExternalImage.php
#	src/FileSize.php
#	src/URLHelper.php

1134 of 1134 new or added lines in 55 files covered. (100.0%)

3923 of 4430 relevant lines covered (88.56%)

59.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/Integration/CLI/TimberCommand.php
1
<?php
2

3
namespace Timber\Integration\CLI;
4

5
use Timber\Cache\Cleaner;
6
use WP_CLI;
7
use WP_CLI_Command;
8

9
if (!\class_exists('WP_CLI_Command')) {
1✔
10
    return;
×
11
}
12

13
/**
14
 * Class TimberCommand
15
 *
16
 * Handles WP-CLI commands.
17
 */
18
class TimberCommand extends WP_CLI_Command
19
{
20
    /**
21
     * Clears caches in Timber.
22
     *
23
     * ## OPTIONS
24
     *
25
     * [<mode>]
26
     * : Optional. The type of cache to clear. Accepts 'timber' or 'twig'. If not provided, the command will clear all caches.
27
     *
28
     * ## EXAMPLES
29
     *
30
     *    # Clear all caches.
31
     *    wp timber clear-cache
32
     *
33
     *    # Clear Timber caches.
34
     *    wp timber clear-cache timber
35
     *
36
     *    # Clear Twig caches.
37
     *    wp timber clear-cache twig
38
     *
39
     * @subcommand clear-cache
40
     * @alias clear_cache
41
     */
42
    public function clear_cache($args = [])
43
    {
44
        $mode = $args[0] ?? 'all';
6✔
45
        $mode_string = 'all' !== $mode ? \ucfirst($mode) : $mode;
6✔
46

47
        WP_CLI::log("Clearing {$mode_string} caches …");
6✔
48

49
        if (Cleaner::clear_cache($mode)) {
6✔
50
            WP_CLI::success("Cleared {$mode_string} caches.");
6✔
51
        } else {
52
            WP_CLI::warning("Failed to clear {$mode_string} cached contents.");
×
53
        }
54
    }
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc