Completed
Push — master ( bff7dd...088f50 )
by Samuel
14:43 queued 05:36
created

PHPEvalCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 26
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 1
A execute() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of CacheTool.
5
 *
6
 * (c) Samuel Gordalina <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Command;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class PHPEvalCommand extends AbstractCommand
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 20
    protected function configure()
24
    {
25
        $this
26 20
            ->setName('php:eval')
27 20
            ->setDescription('Run a specified PHP code')
28 20
            ->addArgument('code', InputArgument::REQUIRED)
29 20
            ->setHelp('In order to use this your PHP code needs to return the value you want to see
30
            example: "return gethostname();"');
31 20
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output): int
37
    {
38
        $code = $input->getArgument('code');
39
        $success = $this->getCacheTool()->_eval($code);
40
        $output->writeln(sprintf("<comment>Eval Output:\n <info>%s</info></comment>", $success));
41
        return 0;
42
    }
43
}
44