ServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 7
Bugs 3 Features 0
Metric Value
wmc 5
eloc 13
c 7
b 3
f 0
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 2
A isLumen() 0 3 1
A register() 0 14 2
1
<?php
2
3
namespace RichanFongdasen\EloquentBlameable;
4
5
use Illuminate\Support\ServiceProvider as Provider;
6
7
class ServiceProvider extends Provider
8
{
9
    /**
10
     * Check if the application runs with Lumen.
11
     *
12
     * @return bool
13
     */
14
    protected function isLumen(): bool
15
    {
16
        return strpos($this->app->version(), 'Lumen') !== false;
17
    }
18
19
    /**
20
     * Bootstrap the application services.
21
     *
22
     * @return void
23
     */
24
    public function boot(): void
25
    {
26
        if (!$this->isLumen()) {
27
            $this->publishes([
28
                realpath(dirname(__DIR__).'/config/blameable.php') => config_path('blameable.php'),
29
            ], 'config');
30
        }
31
    }
32
33
    /**
34
     * Register the application services.
35
     *
36
     * @return void
37
     */
38
    public function register(): void
39
    {
40
        $configPath = realpath(dirname(__DIR__).'/config/blameable.php');
41
42
        if ($configPath !== false) {
43
            $this->mergeConfigFrom($configPath, 'blameable');
44
        }
45
46
        $this->app->singleton(BlameableObserver::class, function (): BlameableObserver {
47
            return new BlameableObserver();
48
        });
49
50
        $this->app->singleton(BlameableService::class, function (): BlameableService {
51
            return new BlameableService();
52
        });
53
    }
54
}
55