Completed
Pull Request — master (#47)
by Robbie
01:27
created

Controller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 13 3
1
<?php
2
3
namespace LeKoala\DebugBar;
4
5
use DebugBar\OpenHandler;
6
use LeKoala\DebugBar\DebugBar;
7
use SilverStripe\Control\Controller as BaseController;
8
use SilverStripe\Control\HTTPRequest;
9
10
/**
11
 * A open handler controller for DebugBar
12
 *
13
 * @author Koala
14
 */
15
class Controller extends BaseController
16
{
17
    public function index(HTTPRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

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

Loading history...
18
    {
19
        if (!DebugBar::config()->enable_storage) {
20
            return $this->httpError(404, 'Storage not enabled');
21
        }
22
        $debugbar = DebugBar::getDebugBar();
23
        if (!$debugbar) {
24
            return $this->httpError(404, 'DebugBar not enabled');
25
        }
26
        $openHandler = new OpenHandler($debugbar);
27
        $openHandler->handle();
28
        exit(); // Handle will echo and set headers
0 ignored issues
show
Coding Style Compatibility introduced by
The method index() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
29
    }
30
}
31