Passed
Push — master ( d3ed66...58a98a )
by Serhii
01:32 queued 10s
created

ElasticSearchServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 33
    public function register(): void
17
    {
18
        $this->app->bind(Client::class, function () {
19 24
            return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build();
20 33
        });
21 33
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 33
    public function boot(): void
27
    {
28 33
        $this->publishes([
29 33
            __DIR__.'/../config/elasticsearch.php' => config_path('elasticsearch.php'),
30 33
        ], 'config');
31 33
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function provides(): array
37
    {
38
        return [Client::class];
39
    }
40
}
41