Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
created

ClearCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 77
ccs 0
cts 32
cp 0
rs 10

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
class ClearCommand extends AbstractController implements CommandInterface
22
{
23
	/**
24
	 * The cache item pool.
25
	 *
26
	 * @var  CacheItemPoolInterface
27
	 */
28
	private $cache;
29
30
	/**
31
	 * Constructor.
32
	 *
33
	 * @param   CacheItemPoolInterface  $cache  The cache item pool
34
	 */
35
	public function __construct(CacheItemPoolInterface $cache)
36
	{
37
		$this->cache = $cache;
38
	}
39
40
	/**
41
	 * Execute the controller.
42
	 *
43
	 * @return  boolean
44
	 */
45
	public function execute()
46
	{
47
		$this->getApplication()->outputTitle('Cache: Clear');
48
49
		$this->cache->clear();
50
51
		$this->getApplication()->out('<info>The application cache has been cleared.</info>');
52
53
		return true;
54
	}
55
56
	/**
57
	 * Get the command's description
58
	 *
59
	 * @return  string
60
	 */
61
	public function getDescription() : string
62
	{
63
		return 'Clear the application cache.';
64
	}
65
66
	/**
67
	 * Get the command's title
68
	 *
69
	 * @return  string
70
	 */
71
	public function getTitle() : string
72
	{
73
		return 'Clear Cache';
74
	}
75
}
76