SuperCacheInvalidateServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
eloc 16
c 4
b 3
f 0
dl 0
loc 40
rs 10
wmc 3

2 Methods

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