ServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 53
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A registerCommand() 0 10 1
A register() 0 10 1
A provides() 0 4 1
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Laravel;
4
5
use Illuminate\Support\ServiceProvider as Provider;
6
use BestServedCold\LaravelZendSearch\Laravel\Console\Rebuild;
7
use BestServedCold\LaravelZendSearch\Laravel\Console\Destroy;
8
use BestServedCold\LaravelZendSearch\Laravel\Console\Optimise;
9
10
/**
11
 * Class ServiceProvider
12
 * @package BestServedCold\LaravelZendSearch\Laravel
13
 */
14
class ServiceProvider extends Provider
15
{
16
    /**
17
     * Bootstrap the application services.
18
     *
19
     * @return             void
20
     * @codeCoverageIgnore
21
     */
22
    public function boot()
23
    {
24
        $this->mergeConfigFrom(__DIR__.'/../../../config/search.php', 'search');
25
    }
26
27
    /**
28
     * @param string $command
29
     */
30 51
    private function registerCommand($command)
31
    {
32 51
        $reflection = new \ReflectionClass($command);
33 51
        $this->app->singleton(
34 51
            'command.search.'.strtolower($reflection->getShortName()),
35 7
            function() use ($command) {
36 7
                return new $command;
37
            }
38 51
        );
39 51
    }
40
41
    /**
42
     * Register the application services.
43
     *
44
     * @return             void
45
     * @codeCoverageIgnore
46
     */
47
    public function register()
48
    {
49
        $this->publishes([__DIR__.'/../../../config/search.php' => app()->basePath().'/config'.('search.php'), ]);
50
51
        $this->registerCommand(Rebuild::class);
52
        $this->registerCommand(Destroy::class);
53
        $this->registerCommand(Optimise::class);
54
55
        $this->commands(['command.search.rebuild', 'command.search.optimise', 'command.search.destroy']);
56
    }
57
58
59
    /**
60
     * @return array
61
     */
62 1
    public function provides()
63
    {
64 1
        return ['search', 'command.search.rebuild', 'command.search.optimise', 'command.search.destroy'];
65
    }
66
}
67