Completed
Pull Request — master (#444)
by Yanick
02:51
created

LiteSpeedProxy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 75
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 20 2
A stop() 0 7 1
A clear() 0 12 1
A setCacheDir() 0 4 1
A getCacheDir() 0 4 1
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
class LiteSpeedProxy extends AbstractProxy
15
{
16
    protected $binary = '/usr/local/lsws/bin/lswsctrl';
17
18
    protected $port = 8080;
19
20
    protected $cacheDir = '/usr/local/lsws/cachedata';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function start()
26
    {
27
        $process = $this->runCommand([
28
            $this->getBinary(),
29
            'status',
30
        ], true);
31
32
        // Already running
33
        if (false !== strpos($process->getOutput(), 'litespeed is running with PID')) {
34
            return;
35
        }
36
37
        // Starting deamonized
38
        $this->runCommand([
39
            $this->getBinary(),
40
            'start',
41
        ], true);
42
43
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function stop()
50
    {
51
        $this->runCommand([
52
            $this->getBinary(),
53
            'stop',
54
        ], true);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function clear()
61
    {
62
        var_dump(scandir($this->getCacheDir()));
0 ignored issues
show
Security Debugging Code introduced by
var_dump(scandir($this->getCacheDir())); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
63
64
        $this->runCommand([
65
            'rm',
66
            '-rf',
67
            $this->getCacheDir(),
68
        ], true);
69
70
        $this->start();
71
    }
72
73
    /**
74
     * @param string $cacheDir
75
     */
76
    public function setCacheDir($cacheDir)
77
    {
78
        $this->cacheDir = $cacheDir;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getCacheDir()
85
    {
86
        return $this->cacheDir;
87
    }
88
}
89