QuitCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A quit() 0 5 1
A execute() 0 3 1
A configure() 0 4 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\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Description of QuitCommand.
13
 *
14
 * @author kdudas
15
 */
16
class QuitCommand extends Command
17
{
18
    private $serviceManager;
19
20
    public function __construct($config, $name = null)
21
    {
22
        parent::__construct($name);
23
        $this->serviceManager = new ServiceManager($config);
24
    }
25
26
    protected function configure()
27
    {
28
        $this->setName('quit');
29
        $this->setHelp('Close the server process');
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $this->quit();
35
    }
36
37
    private function quit()
38
    {
39
        /* @var $client CacheClient */
40
        $client = $this->serviceManager->get(CacheClient::class);
41
        $client->quitServer();
42
    }
43
}
44