Completed
Push — master ( 10f95b...bf15d4 )
by Michael
09:02
created

ClearCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 64
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 10 1
A getDescription() 0 4 1
A getTitle() 0 4 1
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Commands\Cache;
10
11
use Joomla\Controller\AbstractController;
12
use Joomla\StatsServer\CommandInterface;
13
use Psr\Cache\CacheItemPoolInterface;
14
15
/**
16
 * CLI command for clearing the application cache
17
 *
18
 * @method         \Joomla\StatsServer\CliApplication  getApplication()  Get the application object.
19
 * @property-read  \Joomla\StatsServer\CliApplication  $app              Application object
20
 *
21
 * @since          1.0
22
 */
23
class ClearCommand extends AbstractController implements CommandInterface
24
{
25
	/**
26
	 * The cache item pool.
27
	 *
28
	 * @var    CacheItemPoolInterface
29
	 * @since  1.0
30
	 */
31
	private $cache;
32
33
	/**
34
	 * Constructor.
35
	 *
36
	 * @param   CacheItemPoolInterface  $cache  The cache item pool
37
	 *
38
	 * @since   1.0
39
	 */
40
	public function __construct(CacheItemPoolInterface $cache)
41
	{
42
		$this->cache = $cache;
43
	}
44
45
	/**
46
	 * Execute the controller.
47
	 *
48
	 * @return  boolean
49
	 *
50
	 * @since   1.0
51
	 */
52
	public function execute()
53
	{
54
		$this->getApplication()->outputTitle('Cache: Clear');
55
56
		$this->cache->clear();
57
58
		$this->getApplication()->out('<info>The application cache has been cleared.</info>');
59
60
		return true;
61
	}
62
63
	/**
64
	 * Get the command's description
65
	 *
66
	 * @return  string
67
	 *
68
	 * @since   1.0
69
	 */
70
	public function getDescription() : string
71
	{
72
		return 'Clear the application cache.';
73
	}
74
75
	/**
76
	 * Get the command's title
77
	 *
78
	 * @return  string
79
	 *
80
	 * @since   1.0
81
	 */
82
	public function getTitle() : string
83
	{
84
		return 'Clear Cache';
85
	}
86
}
87