SecurityTxtController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 10 2
A redirect() 0 7 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