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

ClearCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
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