DebugBarController::index()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LeKoala\DebugBar;
4
5
use DebugBar\OpenHandler;
6
use LeKoala\DebugBar\DebugBar;
7
use SilverStripe\Control\Controller;
8
use SilverStripe\Control\HTTPRequest;
9
10
/**
11
 * A open handler controller for DebugBar
12
 *
13
 * @author Koala
14
 */
15
class DebugBarController extends Controller
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. ( Ignorable by Annotation )

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

17
    public function index(/** @scrutinizer ignore-unused */ HTTPRequest $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...
18
    {
19
        if (!DebugBar::config()->get('enable_storage')) {
20
            return $this->httpError(404, 'Storage not enabled');
21
        }
22
        $debugbar = DebugBar::getDebugBar();
23
        if (!$debugbar) {
0 ignored issues
show
introduced by
$debugbar is of type DebugBar\DebugBar, thus it always evaluated to true.
Loading history...
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
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
29
    }
30
}
31