ElasticsearchServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php namespace Nord\Lumen\Elasticsearch;
2
3
use Elasticsearch\ClientBuilder;
4
use Illuminate\Support\ServiceProvider;
5
use Nord\Lumen\Elasticsearch\Contracts\ElasticsearchServiceContract;
6
7
class ElasticsearchServiceProvider extends ServiceProvider
8
{
9
    protected const CONFIG_KEY = 'elasticsearch';
10
11
12
    /**
13
     * @inheritdoc
14
     */
15
    public function register()
16
    {
17
        /** @noinspection PhpUndefinedMethodInspection */
18
        $this->app->/** @scrutinizer ignore-call */ configure(self::CONFIG_KEY);
19
20
        $this->registerBindings();
21
    }
22
23
24
    /**
25
     * Register bindings.
26
     */
27
    protected function registerBindings()
28
    {
29
        /** @noinspection PhpUndefinedMethodInspection */
30
        $config = $this->app['config']->get('elasticsearch', []);
31
32
        $this->app->/** @scrutinizer ignore-call */ singleton(ElasticsearchServiceContract::class, function () use ($config) {
33
            return new ElasticsearchService(ClientBuilder::fromConfig($config));
34
        });
35
    }
36
}
37