Passed
Push — main ( 7a6063...0cf387 )
by Lorenzo
10:35
created

SuperCacheInvalidateServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
A boot() 0 15 2
1
<?php
2
3
namespace Padosoft\SuperCacheInvalidate;
4
5
use Illuminate\Support\ServiceProvider;
6
use Padosoft\SuperCacheInvalidate\Console\ProcessCacheInvalidationEventsCommand;
7
use Padosoft\SuperCacheInvalidate\Console\PruneCacheInvalidationDataCommand;
8
use Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper;
9
10
class SuperCacheInvalidateServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register bindings in the container.
14
     */
15
    public function register(): void
16
    {
17
        // Merge package configuration
18
        $this->mergeConfigFrom(
19
            __DIR__ . '/../../config/super_cache_invalidate.php',
20
            'super_cache_invalidate'
21
        );
22
23
        // Register the helper as a singleton
24
        $this->app->singleton('supercache.invalidation', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app 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

24
        $this->app->singleton('supercache.invalidation', function (/** @scrutinizer ignore-unused */ $app) {

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...
25
            return new SuperCacheInvalidationHelper();
26
        });
27
    }
28
29
    /**
30
     * Perform post-registration booting of services.
31
     */
32
    public function boot(): void
33
    {
34
        // Publish configuration
35
        $this->publishes([
36
            __DIR__ . '/../../config/super_cache_invalidate.php' => config_path('super_cache_invalidate.php'),
37
        ], 'config');
38
39
        // Publish migrations
40
        $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
41
42
        // Register commands
43
        if ($this->app->runningInConsole()) {
44
            $this->commands([
45
                ProcessCacheInvalidationEventsCommand::class,
46
                PruneCacheInvalidationDataCommand::class,
47
            ]);
48
        }
49
    }
50
}
51