Completed
Push — master ( b8763b...0e0e56 )
by Pavel
05:40
created

BackupPanel::check()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 1
nop 1
1
<?php
2
3
namespace PavelMironchik\BackupPanel;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
8
class BackupPanel
9
{
10
    /**
11
     * The callback that should be used to authenticate Laravel Backup Panel users.
12
     *
13
     * @var Closure
14
     */
15
    public static $authUsing;
16
17
    /**
18
     * Determine if the given request can access the Laravel Backup Panel dashboard.
19
     *
20
     * @param  Request  $request
21
     * @return bool
22
     */
23
    public static function check($request)
24
    {
25
        return (static::$authUsing ?: function () {
26
            return app()->environment('local');
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

26
            return app()->/** @scrutinizer ignore-call */ environment('local');
Loading history...
27
        })($request);
28
    }
29
30
    /**
31
     * Set the callback that should be used to authenticate Laravel Backup Panel users.
32
     *
33
     * @param  Closure  $callback
34
     * @return static
35
     */
36
    public static function auth(Closure $callback)
37
    {
38
        static::$authUsing = $callback;
39
40
        return new static;
41
    }
42
43
    /**
44
     * Get the default JavaScript variables for Laravel Backup Panel.
45
     *
46
     * @return array
47
     */
48
    public static function scriptVariables()
49
    {
50
        return [
51
            'appName' => config('app.name'),
52
            'path' => config('backup_panel.path'),
53
        ];
54
    }
55
}
56