ProxyClearController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace mxdiModule\Controller;
3
4
use Zend\Mvc\Controller\AbstractConsoleController;
5
6
class ProxyClearController extends AbstractConsoleController
7
{
8
    /**
9
     * @var string
10
     */
11
    protected $proxyDir;
12
13
    /**
14
     * @param string $proxyDir
15
     */
16 4
    public function __construct($proxyDir)
17
    {
18 4
        $this->proxyDir = $proxyDir;
19 4
    }
20
21
    /**
22
     * Clear proxy files.
23
     *
24
     * @return int
25
     */
26 3
    public function indexAction()
27
    {
28 3
        if (empty($this->proxyDir)) {
29 1
            $this->getConsole()->writeLine('Proxy dir is not set or empty');
30 1
            return -1;
31
        }
32
33 2
        if (! is_dir($this->proxyDir)) {
34 1
            $this->getConsole()->writeLine('Proxy dir does not exist');
35 1
            return -1;
36
        }
37
38 1
        foreach (glob($this->proxyDir . '/*.php') as $file) {
39 1
            unlink($file);
40 1
        }
41
42 1
        return 0;
43
    }
44
45
    /**
46
     * @return string
47
     */
48 1
    public function getProxyDir()
49
    {
50 1
        return $this->proxyDir;
51
    }
52
}
53