QuitCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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