LaravelBackupPanel::auth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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