Completed
Push — 1.x ( 2f995a...fa8c59 )
by Samuel
18:04
created

Cli::doRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
nc 1
cc 1
eloc 7
nop 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\Adapter;
13
14
use CacheTool\Code;
15
use Symfony\Component\Process\Process;
16
17
class Cli extends AbstractAdapter
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function doRun(Code $code)
23
    {
24
        $file = $this->createTemporaryFile();
25
        $code->writeTo($file);
26
27
        $process = new Process("php $file");
28
        $process->run();
29
30
        @unlink($file);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
31
32
        return $process->getOutput();
33
    }
34
}
35