Issues (22)

src/DynamicExport.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace NovaResourceDynamicExport;
4
5
use Closure;
6
7
class DynamicExport
8
{
9
    /**
10
     * Indicates if NovaExportConfiguration migrations will be run.
11
     */
12
    public static bool $runsMigrations = true;
13
14
    /**
15
     * Indicates if NovaExportConfiguration will provide download route.
16
     */
17
    public static bool $useRoutes = true;
18
19
    /**
20
     * Route Configuration callback
21
     */
22
    public static Closure|null $routeConfigurationCallback = null;
23
24
    public static function ignoreMigrations(): static
25
    {
26
        static::$runsMigrations = false;
27
28
        return new static;
29
    }
30
31
    public static function withoutRoutes(): static
32
    {
33
        static::$useRoutes = false;
34
35
        return new static;
36
    }
37
38 10
    public static function routeConfiguration(?\Closure $callback = null): mixed
39
    {
40 10
        if($callback) {
41
            static::$routeConfigurationCallback = $callback;
42
43
            return new static;
44
        }
45
46 10
        if(is_callable(static::$routeConfigurationCallback)) {
47
            return call_user_func(static::$routeConfigurationCallback);
0 ignored issues
show
It seems like static::routeConfigurationCallback can also be of type null; however, parameter $callback of call_user_func() does only seem to accept callable, maybe add an additional type check? ( Ignorable by Annotation )

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

47
            return call_user_func(/** @scrutinizer ignore-type */ static::$routeConfigurationCallback);
Loading history...
48
        }
49
50 10
        return [
51 10
            'prefix'     => 'downloads/exports',
52 10
            'middleware' => config('nova.middleware'),
53 10
        ];
54
    }
55
56
}
57