Passed
Push — master ( a4a58e...30c82e )
by Krisztián
02:29
created

src/Commands/SetCommand.php (1 issue)

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
10
/**
11
 * Description of SetCommand.
12
 *
13
 * @author dude920228
14
 */
15
class SetCommand extends Command
16
{
17
    private $serviceManager;
18
19
    public function __construct($config, $name = null)
20
    {
21
        parent::__construct($name);
22
        $this->serviceManager = new ServiceManager($config);
23
    }
24
25
    protected function configure()
26
    {
27
        $this->setName('set');
28
        $this->setHelp('This command allows you to create entries in the cache pool');
29
        $this->addArgument('key', InputArgument::REQUIRED, 'The key assigned to the cache entry');
30
        $this->addArgument('value', InputArgument::REQUIRED, 'The value of the cache entry');
31
    }
32
33
    protected function execute($input, $output)
34
    {
35
        $this->set($input, $output);
36
    }
37
38
    private function set($input, $output)
0 ignored issues
show
The parameter $output is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    private function set($input, /** @scrutinizer ignore-unused */ $output)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40
        /* @var $client CacheClient */
41
        $client = $this->serviceManager->get(CacheClient::class);
42
        $client->set($input->getArgument('key'), $input->getArgument('value'));
43
    }
44
}
45