Completed
Push — master ( f146ce...fa6bcb )
by Samuel
02:58 queued 30s
created

Cli::doRun()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0438

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 9
cp 0.7778
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2.0438
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\Adapter;
13
14
use CacheTool\Code;
15
use Symfony\Component\Process\Process;
16
17
class Cli extends AbstractAdapter
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 2
    protected function doRun(Code $code)
23
    {
24 2
        $file = $this->createTemporaryFile();
25 2
        $code->writeTo($file);
26
27 2
        $process = new Process("php $file");
28 2
        $process->run();
29
30 2
        if (!@unlink($file)) {
31
            $this->logger->debug(sprintf('CLI: Could not delete file: %s', $file));
32
        }
33
34 2
        return $process->getOutput();
35
    }
36
}
37