Completed
Push — master ( 8b149d...d0a098 )
by Kevin
07:29
created

BanController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A indexAction() 0 3 1
A banTypo3PagesAction() 0 16 3
A banTagByNameAction() 0 16 3
1
<?php
2
namespace Aoe\Varnish\Controller;
3
4
use Aoe\Varnish\Domain\Model\Tag\PageTag;
5
use Aoe\Varnish\Domain\Model\Tag\Tag;
6
use Aoe\Varnish\System\Varnish;
7
use TYPO3\CMS\Core\Messaging\AbstractMessage;
8
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
9
10
class BanController extends ActionController
11
{
12
    /**
13
     * @var Varnish
14
     */
15
    private $varnish;
16
17
    /**
18
     * @param Varnish $varnish
19
     */
20
    public function __construct(Varnish $varnish)
21
    {
22
        $this->varnish = $varnish;
23
        parent::__construct();
24
    }
25
26
    public function indexAction()
27
    {
28
    }
29
30
    public function banTypo3PagesAction()
31
    {
32
        $results = $this->varnish
33
            ->banByTag(new PageTag('typo3_pages'))
0 ignored issues
show
Unused Code introduced by
The call to PageTag::__construct() has too many arguments starting with 'typo3_pages'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
            ->shutdown();
35
36
        foreach ($results as $result) {
37
            if ($result['success']) {
38
                $this->addFlashMessage($result['reason']);
39
            } else {
40
                $this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR);
41
            }
42
        }
43
44
        $this->redirect('index');
45
    }
46
47
    /**
48
     * @param string $tagName
49
     */
50
    public function banTagByNameAction($tagName)
51
    {
52
        $results = $this->varnish
53
            ->banByTag(new Tag($tagName))
54
            ->shutdown();
55
56
        foreach ($results as $result) {
57
            if ($result['success']) {
58
                $this->addFlashMessage($result['reason']);
59
            } else {
60
                $this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR);
61
            }
62
        }
63
64
        $this->redirect('index');
65
    }
66
}
67