BindingServiceProvider::registeringPackage()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 3
eloc 4
c 3
b 1
f 0
nc 4
nop 0
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\AutoBinder;
6
7
use Illuminate\Cache\CacheServiceProvider;
8
use Illuminate\Redis\RedisServiceProvider;
9
use MichaelRubel\AutoBinder\Commands\AutoBinderClearCommand;
10
use Spatie\LaravelPackageTools\Package;
11
use Spatie\LaravelPackageTools\PackageServiceProvider;
12
13
class BindingServiceProvider extends PackageServiceProvider
14
{
15
    /**
16
     * Configure the package.
17
     */
18 26
    public function configurePackage(Package $package): void
19
    {
20 26
        $package
21 26
            ->name('laravel-auto-binder')
22 26
            ->hasCommand(AutoBinderClearCommand::class);
23
    }
24
25
    /**
26
     * Register bindings.
27
     */
28 26
    public function registeringPackage(): void
29
    {
30 26
        if (! $this->app->bound('cache')) {
31 26
            $this->app->register(CacheServiceProvider::class, true);
32
        }
33
34 26
        if (! $this->app->bound('redis')) {
35 26
            $this->app->register(RedisServiceProvider::class);
36
        }
37
    }
38
}
39