DeleteCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 5 1
A execute() 0 3 1
A deleteEntry() 0 6 1
1
<?php
2
3
namespace PhpCache\Commands;
4
5
use PhpCache\CacheClient\CacheClient;
6
use PhpCache\ServiceManager\ServiceManager;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * Description of PhpCache.
14
 *
15
 * @author dude920228
16
 */
17
class DeleteCommand extends Command
18
{
19
    private $serviceManager;
20
21
    public function __construct($config, $name = null)
22
    {
23
        parent::__construct($name);
24
        $this->serviceManager = new ServiceManager($config);
25
    }
26
27
    protected function configure()
28
    {
29
        $this->setName('delete');
30
        $this->setHelp('This command allows you to delete entries from the cache pool by key');
31
        $this->addArgument('key', InputArgument::REQUIRED, 'Key for the cache entry to be deleted');
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $this->deleteEntry($input);
37
    }
38
39
    private function deleteEntry(InputInterface $input)
40
    {
41
        $key = $input->getArgument('key');
42
        /* @var $client CacheClient */
43
        $client = $this->serviceManager->get(CacheClient::class);
44
        $client->delete($key);
45
    }
46
}
47