Completed
Pull Request — master (#444)
by Yanick
04:40 queued 02:25
created

LiteSpeedProxy::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCache package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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 FOS\HttpCache\Test\Proxy;
13
14
use Symfony\Component\Process\Exception\ProcessFailedException;
15
use Symfony\Component\Process\Process;
16
17
class LiteSpeedProxy extends AbstractProxy
18
{
19
    protected $binary = '/usr/local/lsws/bin/lswsctrl';
20
21
    protected $port = 8080;
22
23
    protected $cacheDir = 'cachedata';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function start()
29
    {
30
        try {
31
            $this->runCommand([
32
                $this->getBinary(),
33
                'start',
34
            ], true);
35
        } catch (ProcessFailedException $e) {
36
            var_dump($e->getMessage());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($e->getMessage()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
37
        }
38
39
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function stop()
46
    {
47
        $this->runCommand([
48
            $this->getBinary(),
49
            'stop',
50
        ], true);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function clear()
57
    {
58
        $this->runCommand([
59
            'rm',
60
            '-rf',
61
            $this->getCacheDir(),
62
        ], true);
63
64
        $this->runCommand([
65
            'mkdir',
66
            $this->getCacheDir(),
67
        ], true);
68
69
        $this->start();
70
    }
71
72
    /**
73
     * @param string $cacheDir
74
     */
75
    public function setCacheDir($cacheDir)
76
    {
77
        $this->cacheDir = $cacheDir;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getCacheDir()
84
    {
85
        return $this->cacheDir;
86
    }
87
}
88