ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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