Passed
Push — main ( 44f9b3...d7b1c0 )
by Yaroslav
02:39
created

ServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 96.3%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 56
ccs 26
cts 27
cp 0.963
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A routes() 0 14 3
A boot() 0 19 2
1
<?php
2
3
namespace NovaChunkedVideo;
4
5
use Illuminate\Support\Facades\Route;
6
use Laravel\Nova\Events\ServingNova;
7
use Laravel\Nova\Nova;
8
9
class ServiceProvider extends \Illuminate\Support\ServiceProvider
10
{
11
    /**
12
     * Bootstrap any application services.
13
     *
14
     * @return void
15
     */
16 13
    public function boot()
17
    {
18 13
        if ($this->app->runningInConsole()) {
19 13
            $this->publishes([
20 13
                __DIR__ . '/../config/nova-chunked.php' => config_path('nova-chunked.php'),
21 13
            ], 'config');
22
23
24 13
            $this->commands([
25 13
            ]);
26
        }
27
28 13
        $this->app->booted(function () {
29 13
            $this->routes();
30 13
        });
31
32 13
        Nova::serving(function (ServingNova $event) {
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

32
        Nova::serving(function (/** @scrutinizer ignore-unused */ ServingNova $event) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33 2
            Nova::script('chunked-video', __DIR__.'/../dist/js/field.js');
34 2
            Nova::style('chunked-video', __DIR__.'/../dist/css/field.css');
35 13
        });
36
    }
37
38
    /**
39
     * Register any application services.
40
     *
41
     * @return void
42
     */
43 13
    public function register()
44
    {
45 13
        $this->mergeConfigFrom(__DIR__ . '/../config/nova-chunked.php', 'nova-chunked');
46
    }
47
48
    /**
49
     * Register the card's routes.
50
     */
51 13
    protected function routes()
52
    {
53 13
        if ($this->app->routesAreCached()) {
54
            return;
55
        }
56
57 13
        Route::middleware(['nova'])
58 13
             ->prefix('nova-vendor/nova-chunked')
59 13
             ->group(function () {
60 13
                 if (config('nova-chunked.use_package_routes')) {
61 13
                     Route::post(
62 13
                         '/video-upload/{resource}/{resourceId}/{field}',
63 13
                         [ \NovaChunkedVideo\Http\Controllers\VideoController::class, 'store' ]
64 13
                     )->name('nova.chunked-video.upload');
65
                 }
66 13
             });
67
    }
68
}
69