Passed
Pull Request — master (#15)
by Serhii
06:06
created

ElasticSearchServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A register() 0 4 1
A provides() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Matchish\ScoutElasticSearch;
6
7
use Elasticsearch\Client;
8
use Elasticsearch\ClientBuilder;
9
use Illuminate\Support\ServiceProvider;
10
11
final class ElasticSearchServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 40
    public function register(): void
17
    {
18
        $this->app->bind(Client::class, function () {
19 29
            return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build();
20 40
        });
21 40
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 40
    public function boot(): void
27
    {
28 40
        $this->publishes([
29 40
            __DIR__.'/../config/elasticsearch.php' => config_path('elasticsearch.php'),
30 40
        ], 'config');
31 40
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 1
    public function provides(): array
37
    {
38 1
        return [Client::class];
39
    }
40
}
41