ScoutElasticServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 1
1
<?php
2
3
namespace Alhoqbani\Elastic;
4
5
use Elasticsearch\ClientBuilder;
6
use Illuminate\Support\ServiceProvider;
7
use Laravel\Scout\EngineManager;
8
9
class ScoutElasticServiceProvider extends ServiceProvider
10
{
11
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
20
        $this->app->make(EngineManager::class)->extend('elastic', function () {
21
22
            $hosts = $this->app['config']->get('services.scout-elastic.hosts');
23
24
            $client = ClientBuilder::create()
25
                ->setHosts($hosts)
26
                ->build();
27
28
            return new ScoutElasticEngine($client);
29
        });
30
31
        $this->publishes([
32
            __DIR__ . '/../config/scout-elastic.php' =>
33
                $this->app['path.config'] . DIRECTORY_SEPARATOR . 'scout-elastic.php',
34
        ]);
35
    }
36
}
37