LaravelBackupPanel   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A auth() 0 5 1
A check() 0 5 2
1
<?php
2
3
namespace PavelMironchik\LaravelBackupPanel;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\App;
8
9
class LaravelBackupPanel
10
{
11
    /**
12
     * The callback that should be used to authenticate Laravel Backup Panel users.
13
     *
14
     * @var Closure
15
     */
16
    public static $authUsing;
17
18
    /**
19
     * Determine if the given request can access the Laravel Backup Panel dashboard.
20
     *
21
     * @param  Request  $request
22
     * @return bool
23
     */
24
    public static function check($request)
25
    {
26
        return (static::$authUsing ?: function () {
27
            return App::environment('local');
28
        })($request);
29
    }
30
31
    /**
32
     * Set the callback that should be used to authenticate Laravel Backup Panel users.
33
     *
34
     * @param  Closure  $callback
35
     * @return static
36
     */
37
    public static function auth(Closure $callback)
38
    {
39
        static::$authUsing = $callback;
40
41
        return new static;
42
    }
43
}
44