SecurityTxtController::show()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * src/SecurityTxtController.php.
4
 *
5
 * @author      Austin Heap <[email protected]>
6
 * @version     v0.4.0
7
 */
8
declare(strict_types=1);
9
10
namespace AustinHeap\Security\Txt;
11
12
use Response;
13
14
/**
15
 * SecurityTxtController.
16
 *
17
 * @link        https://github.com/austinheap/laravel-security-txt
18
 * @link        https://packagist.org/packages/austinheap/laravel-security-txt
19
 * @link        https://austinheap.github.io/laravel-security-txt/classes/AustinHeap.Security.Txt.SecurityTxtController.html
20
 * @link        https://securitytext.org/
21
 */
22
class SecurityTxtController extends \Illuminate\Routing\Controller
23
{
24
    /**
25
     * Show the security.txt file.
26
     *
27
     * @return Response
28
     */
29 2
    public function show()
30
    {
31 2
        if (! config('security-txt.enabled', false)) {
32 1
            abort(404);
33
        }
34
35 1
        return Response::make(
36 1
            app('SecurityTxt')->fetch(),
37 1
            200,
38 1
            ['Content-Type' => 'text/plain']
39
        );
40
    }
41
42
    /**
43
     * Redirect to the proper location of the security.txt file.
44
     *
45
     * @return Response
46
     */
47 2
    public function redirect()
48
    {
49 2
        if (! config('security-txt.enabled', false)) {
50 1
            abort(404);
51
        }
52
53 1
        return redirect()->route('security.txt');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route('security.txt') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Response.
Loading history...
54
    }
55
}
56