ProxyClearController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 47
wmc 6
lcom 1
cbo 2
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A indexAction() 0 18 4
A getProxyDir() 0 4 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