AdminController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B clearcacheAction() 0 27 5
1
<?php
2
/**
3
 * Copyright (c) 2017
4
 *
5
 * @package   Majima
6
 * @author    David Neustadt <[email protected]>
7
 * @copyright 2017 David Neustadt
8
 * @license   MIT
9
 */
10
11
namespace Majima\Controller;
12
13
use Symfony\Component\DependencyInjection\Container;
14
use Symfony\Component\Filesystem\Filesystem;
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Routing\RouterInterface;
19
20
/**
21
 * Class AdminController
22
 * @package Majima\Controller
23
 */
24
class AdminController
25
{
26
    /**
27
     * @var Container
28
     */
29
    protected $container;
30
31
    /**
32
     * @var RouterInterface
33
     */
34
    protected $router;
35
36
    /**
37
     * AdminController constructor.
38
     * @param Container $container
39
     * @param RouterInterface $router
40
     */
41
    public function __construct(Container $container, RouterInterface $router)
42
    {
43
        $this->container = $container;
44
        $this->router = $router;
45
    }
46
47
    /**
48
     * @param Request $request
49
     * @return Response
50
     */
51
    public function clearcacheAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
    public function clearcacheAction(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        $fs = new Filesystem();
54
        $fs->remove($this->container->getParameter('kernel.cache_dir'));
55
56
        $cssPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'css', 'style.min.css']);
0 ignored issues
show
Bug introduced by
The constant Majima\Controller\BASE_DIR was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
57
        $backendCssPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'css', 'style.backend.min.css']);
58
        $jsPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'js', 'scripts.min.js']);
59
        $backendJsPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'js', 'scripts.backend.min.js']);
60
61
        if (file_exists($cssPath)) {
62
            $fs->remove($cssPath);
63
        }
64
65
        if (file_exists($backendCssPath)) {
66
            $fs->remove($backendCssPath);
67
        }
68
69
        if (file_exists($jsPath)) {
70
            $fs->remove($jsPath);
71
        }
72
73
        if (file_exists($backendJsPath)) {
74
            $fs->remove($backendJsPath);
75
        }
76
77
        return new RedirectResponse($this->router->generate('index_index'));
78
    }
79
}